ubuntu16.04下python2、python3環境選擇與python升級
阿新 • • 發佈:2018-05-29
pip3 eba 更換 rac 查看 ror 使用 tps 切換
參考鏈接:https://www.jianshu.com/p/63c1f22e1fed
Ubuntu中python版本問題:
- 添加PPA:
sudo add-apt-repository ppa:jonathonf/python-3.6
- 查看更新和安裝更新:
sudo apt-get update
sudo apt-get install python3.6
- 更換命令行中的python默認版本
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
-
查看python默認版本
python -V
-
切換版本:
sudo update-alternatives --config python3
Ubuntu中python升級到3.6:
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
sudo apt install spyder3
sudo rm /usr/bin/python
sudo ln -s /usr/local/bin/python3.6 /usr/bin/python
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
sudo update-alternatives --config python3
python -V
更新:
2018-05-29 08:58:06
升級到python3.6 後使用pip install遇到問題:
import apt File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module> import apt_pkg ModuleNotFoundError: No module named ‘apt_pkg‘ Original exception was: Traceback (most recent call last): File "/home/osk/.local/bin/pip3", line 7, in <module> from pip._internal import main ModuleNotFoundError: No module named ‘pip._internal‘
解決方案:
重新將ubuntu16.04默認的python3.5版本設置為優先級
ubuntu16.04下python2、python3環境選擇與python升級