美文网首页我爱编程
python和pip版本切换

python和pip版本切换

作者: 南风无影 | 来源:发表于2018-05-24 12:20 被阅读2087次

    玩深度学习,经常遇到工程python版本不一致的情况,需要频繁切换版本号
    一般ubuntu16.04默认的是2.7

    python 3.5

    sudo apt-get install python-software-properties
    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:fkrull/deadsnakes
    sudo apt-get update
    sudo apt-get install python3.5
    sudo cp /usr/bin/python /usr/bin/python_bak
    sudo rm /usr/bin/python
    sudo ln -s /usr/bin/python3.5 /usr/bin/python
    python --version
    

    install pip3.5

    wget https://bootstrap.pypa.io/get-pip.py  
    sudo python3 get-pip.py  
    sudo pip3 install setuptools --upgrade  
    sudo pip3 install ipython[all]
    

    install python 3.6 和对应的pip

    sudo add-apt-repository ppa:jonathonf/python-3.6  # (only for 16.04 LTS)
    sudo apt update
    sudo apt install python3.6
    sudo apt install python3.6-dev
    sudo apt install python3.6-venv
    wget https://bootstrap.pypa.io/get-pip.py
    sudo python3.6 get-pip.py
    sudo ln -s /usr/bin/python3.6 /usr/local/bin/python3
    sudo ln -s /usr/local/bin/pip /usr/local/bin/pip3
    

    When you have completed all of the above, each of the following shell commands should indicate Python 3.6.1 (or a more recent version of Python 3.6):

    python --version   # (this will reflect your choice, see above)
    python3 --version
    $(head -1 `which pip` | tail -c +3) --version
    $(head -1 `which pip3` | tail -c +3) --version
    

    安装python3对应的tensorflow. e.g.

    pip3 install -I tensorflow-gpu==1.4.1
    

    错误1:
    /usr/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6

    解决方案:
    python3.6 -m pip install --upgrade --user tensorflow

    相关文章

      网友评论

        本文标题:python和pip版本切换

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