今天用了下阿里雲的雲服務器,裝個python3真是各類踩坑。記錄下吧:
ubuntu自帶了2.7。想要裝3.5並設置爲默認python版本。javascript
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.5
python --version
sudo apt-get install python3-pip #裝pip3
直接執行這兩個命令便可:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
若是要切換到Python2,執行:
sudo update-alternatives --config python
按照提示輸入選擇數字回車便可。java
解決方法很是簡單,終端輸入如下命令便可:
sudo apt-get updatepython
sudo add-apt-repository ppa:fkrull/deadsnakes
ubuntu add-apt-repository: command not foundubuntu
因此先:bash
sudo apt-get install python-software-properties sudo apt-get install software-properties-common
Traceback (most recent call last):
File 「/usr/bin/pip3」, line 9, in
from pip import main
或者pip 時也出現這個問題
這是pip 10.0.0版本的BUG
修改 /usr/bin/pip 文件:服務器
from pip import main if __name__ == '__main__': sys.exit(main())
改成:阿里雲
from pip import __main__ if __name__ == '__main__': sys.exit(__main__._main())
做者:meetliuxin
連接:https://www.jianshu.com/p/e50e6d46ea62
spa