sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update -y
sudo apt-get install python3.6 -y
我系統(tǒng)中兩個版本的Python路勁均在這個路勁下
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
查看切換列表中版本情況:
update-alternatives --list python
選擇數(shù)字切換Python版本:
sudo update-alternatives --config python
#安裝pip
wget https://bootstrap.pypa.io/get-pip.py? --no-check-certificate
python3 get-pip.py
#安裝python3.6-dev
apt-get install python3.6-dev
若上述運行sudo add-apt-repository ppa:deadsnakes/ppa 出現(xiàn) “bash: add-apt-repository: command not found” 則先運行:
sudo apt-get install -y software-properties-common
看當(dāng)前python鏈接的是哪個版本
whereis python
刪除軟鏈接
rm /usr/bin/python
生成制定python版本的軟鏈接
ln -s /usr/bin/python3.x /usr/bin/python
配置只輸入python3時就默認(rèn)使用3.6版本:
1、update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
2、update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
3、update-alternatives --config python3
4、python3 -V
設(shè)置pip:
1、apt-get install python3-pip # Python3
2、apt-get install python-pip # Python2
pip3 -V
chmod -R 777 test
查看方法:
$: pip3 --version? 或者? pip3.6 --version
6、更新pip
$: pip3.6 install --upgrade pip