執行下面的命令便可。python
sudo apt-get remove --purge python3.5 sudo apt-get remove --auto-remove python3.5 sudo apt-get purge --auto-remove python3.5 sudo apt-get autoclea python3.5
https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz測試
tar -zxvf Python-3.7.3.tgz
cd Python-3.7.3
先安裝ssl包ui
sudo apt-get install openssl sudo apt-get install libssl-dev
而後執行配置命令.net
./configure --with-ssl
不加--with-ssl會致使新的python無法使用pip安裝模塊。報錯以下:命令行
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
make
make test
sudo make install
執行此命令若是出現ModuleNotFoundError: No module named ‘_ctypes’ 錯誤,請執行sudo apt-get install libffi-dev命令code
sudo apt-get install libffi-dev
執行完成後,從新執行sudo make install命令,執行成功:
python的安裝目錄爲:/usr/local/lib/python3.7
blog
輸入python3.7
進入python命令行表示成功。ip
查看系統默認的查看python命令指向ssl
ls -l /usr/bin | grep python
因爲python3.7是本身安裝的,不在/usr/bin下,而在usr/local/bin下,因此使用下面的命令修改python命令指向rem
sudo mv /usr/bin/python /usr/bin/python.bak sudo ln -s /usr/local/python3.7.1/bin/python3.7 /usr/bin/python sudo mv /usr/bin/pip /usr/bin/pip.bak sudo ln -s /usr/local/python3.7.1/bin/pip3 /usr/bin/pip
執行第三條命令sudo mv /usr/bin/pip /usr/bin/pip.bak報錯可不用理會(mv: 沒法獲取'/usr/bin/pip' 的文件狀態(stat): 沒有那個文件或目錄)
輸入python命令驗證
python版本已經變成了3.7.3,修改爲功。
pip -V
參考博客:https://blog.csdn.net/u014775723/article/details/85213793