Ubuntu安装配置切换Python3版本的解决方法
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9
python3.9 --version
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
sudo update-alternatives --config python3
python3 --version
ModuleNotFoundError: No module named 'apt_pkg'问题的解决方法
cd /usr/lib/python3/dist-packages/
sudo ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so
如果报apt_pkg.so已存在,则使用命令
sudo ln -fs apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so
强制添加
参考链接
https://www.itsupportwale.com/blog/how-to-upgrade-to-python-3-7-on-ubuntu-18-10/
安装Python3各版本,根据实际需求切换Python版本
sudo apt install python3.6
sudo apt install python3.7
sudo apt install python3.8
sudo apt install python3.9
sudo update-alternatives --config python3
python3 --version
ImportError: cannot import name 'sysconfig'问题的解决方法
pip3
sudo apt-get remove python3-pip
sudo vim /etc/apt/sources.list
添加如下源
deb http://cn.archive.ubuntu.com/ubuntu bionic main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-updates main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-security main multiverse restricted universe
deb http://cn.archive.ubuntu.com/ubuntu bionic-proposed main multiverse restricted universe
sudo apt-get update
sudo apt upgrade
sudo apt-get install python3-pip
sudo apt-get install python3-distutils
sudo update-alternatives --config python3
python3 --version
如果希望默认python版本为python3,而不是python 2.x, 请参考此教程
https://www.jianshu.com/p/48b1675495e8
欢迎各位关注公众号