python和pip版本切换
程序员文章站
2022-04-18 20:31:51
...
玩深度学习,经常遇到工程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
上一篇: PHP易混淆函数的区别及用法汇总
下一篇: DataTables warning (table id = 'data-table-1'): Requested unknown parameter '9' from the data source
推荐阅读
-
Python 2.7.x 和 3.x 版本的重要区别小结
-
Ubuntu18.04下python版本完美切换的解决方法
-
如何安装多版本python python2和python3共存以及pip共存
-
MacOS配置Anaconda3(Miniconda3)下Python3.6、Python3.7和Python2.7环境和基础机器学习、神经网络相关包详解(版本号对应)
-
Centos7安装python3和pip3(一)
-
Python2和Python3的共存和切换使用
-
python3和pip3、pip脚本一键安装教程
-
python3和pip3、pip脚本一键安装教程
-
Python获取DLL和EXE文件版本号的方法
-
linux(Ubuntu16)下切换python2和python3(转)