1. 程式人生 > >ubuntu中python版本問題

ubuntu中python版本問題

install pip3

在python3環境下安裝包,輸入:

pip3 install matplotlib

(注:系統可能提示你在這之前需要安裝pip3:The program ‘pip3’ is currently not installed. You can install it by typing: >sudo apt install python3-pip)

安裝完成後依次輸入

python 3

import matplotlib

如果沒有報錯說明安裝成功

解除安裝命令:

sudo pip uninstall matplotlib
sudo pip3 uninstall matplotlib

關於版本檢視:

新增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

or

alias
python=python3 # To revert back: alias python=python2

檢視python預設版本

python -V

切換版本:

sudo update-alternatives --config python3

remove python3:

sudo apt-get remove 'python3.*'

切換版本:

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

修改為對應的pip版本

wget https://bootstrap.pypa.io/get-pip.py  --no-check-certificate
sudo python get-pip.py