美文网首页
Python2.7即将退役? 升级到Anaconda3!

Python2.7即将退役? 升级到Anaconda3!

作者: 爱折腾的大懒猪 | 来源:发表于2019-01-25 00:19 被阅读506次

    今天使用conda的PIP, 版本10.0.1, 提示要升级, 于是就pip install --upgrade pip 升级了一下.

    最后就弹出来一段话:

    DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.

    额, Py2.7 要结束支持了, PIP也将不再支持Python2.7....Python2.7 10年的使命也走向了终结...

    看来我也要升级到Python3了... 头痛啊. 先从Anaconda3 开始吧.

    先要把 Anaconda2 给彻底卸载了.

    Anaconda2其实是安装在某个目录下. 例如我装在了~/anaconda2. 不知道为什么, 我最近的conda安装东西一直卡住....估计神经病了, 正好彻底卸载一下.

    根据官方的卸载指导Uninstalling Anaconda, 我选择第二章更干净的卸载.

    conda install anaconda-clean
    anaconda-clean
    # 备份了anaconda到一个文件夹. 不想要了
    rm -rf ~/.anaconda_backup 
    # 在删掉anaconda2 文件夹
    rm -rf ~/anaconda2
    # 删除Anaconda 的应用图标
    rm /Applications/Anaconda-Navigator.app
    # 理论上, 还要在 '.bash_profile' 掉以下类似的话
    export PATH="/Users/用户名/anaconda3/bin:$PATH"
    # 删除Jupyter 残留
    rm -rf ~/.jupyter
    rm -rf ~/Library/Jupyter
    

    好了, 这样就彻底卸载干净了. 包括.matplotlib, .ipython等都被清光了. (其实这个anaconda-clean实际就是删掉了~目录下的 .anaconda .conda .condarc .idlerc .ipynb_checkpoints .ipython .jupyter .matplotlib.

    从官网下载最新的Anaconda 3 (我现在是Anaconda Python 3.7) 后来发现rdkit不支持py3.7, 好吧, 去中科大镜像下载默认Py3.6的Anaconda5.2 (2018.5发布的, 还算比较新).

    安装好后, 先升级conda:

    conda update conda
    

    安装清华源 (包括Conda Forge与bioconda)

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
    conda config --set show_channel_urls yes
    

    好了, 重新安装需要的包:

    # Notebook Extensions 插件扩展
    conda install autopep8 jupyter_contrib_nbextensions
    conda install -c conda-forge jupyter_nbextensions_configurator
    
    ## 生化
    conda install -c rdkit rdkit
    conda install -c openbabel openbabel
    conda install -c anaconda biopython 
    conda install -c conda-forge nglview 
    
    ## 创建一个Python2.7 环境备用
    conda create -n Python27 python=2.7
    source activate Python27
    conda install jupyter autopep8 jupyter_contrib_nbextensions
    conda install -c conda-forge jupyter_nbextensions_configurator
    source deactivate
    

    Python36情况下2018.9的rkdit 安装的libboost是1.67.0版本, 无法使用. 报错:
    ImportError: dlopen(/Users/hom/anaconda3/lib/python3.6/site-packages/rdkit/rdBase.so, 2): > Library not loaded: @rpath/libboost_python3.dylib
    Referenced from: /Users/hom/anaconda3/lib/python3.6/site-packages/rdkit/rdBase.so
    Reason: image not found
    解决办法: conda install libboost=1.65.1

    相关文章

      网友评论

          本文标题:Python2.7即将退役? 升级到Anaconda3!

          本文链接:https://www.haomeiwen.com/subject/qkoejqtx.html