ubuntu16.04下python2、python3環境選擇與python升級

來源:互聯網
上載者:User

標籤:alt   __init__   usr   shu   erro   python2   com   cal   home   

參考連結: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 100sudo 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.6sudo apt-get updatesudo apt-get install python3.6sudo apt install spyder3sudo rm /usr/bin/pythonsudo 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_pkgModuleNotFoundError: 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 mainModuleNotFoundError: No module named ‘pip._internal‘

解決方案:

重新將ubuntu16.04預設的python3.5版本設定為優先順序

 

ubuntu16.04下python2、python3環境選擇與python升級

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.