將 Ubuntu 18.04 的 python 換至 python 3.7
140 字
1 分鐘
將 Ubuntu 18.04 的 python 換至 python 3.7
替換Python版本至3.7
sudo apt update -ysudo apt install python3.7將Python 3.6和Python 3.7添加到更新替代選項
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2更新Python 3以指向Python 3.7
sudo update-alternatives --config python3備用更新Python 3指向Python3.7
sudo rm /usr/bin/python3sudo ln -s python3.7 /usr/bin/python3測試python3的版本
python3 -V錯誤排除
若後續使用python3時出現若「ModuleNotFoundError: No module named ‘apt_pkg’」,則執行以下指令,複製python3.6的套件給python3.7
※其他套件同理,複製一份並將路徑當中之「36m」改為「37m」
cd /usr/lib/python3/dist-packages/ sudo cp apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.cpython-37m-x86_64-linux-gnu.so文章分享
如果這篇文章對你有幫助,歡迎分享給更多人!
將 Ubuntu 18.04 的 python 換至 python 3.7
https://linziyou.info/posts/2020-03-19-將-ubuntu-18-04-的-python-換至-python-3-7/ 最後更新於 2020-03-19,距今已過 2174 天
部分內容可能已過時