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' problem solution
cd /usr/lib/python3/dist-packages/
sudo ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so
If it is reported that apt_pkg.so already exists, use the command
sudo ln -fs apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so
Mandatory add
Reference link
https://www.itsupportwale.com/blog/how-to-upgrade-to-python-3-7-on-ubuntu-18-10/
Install each version of Python3 and switch the Python version according to actual needs
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' problem solution
pip3
sudo apt-get remove python3-pip
sudo vim /etc/apt/sources.list
Add the following source
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
If you want the default python version to be python3 instead of python 2.x, please refer to this tutorial
https://www.jianshu.com/p/48b1675495e8
Welcome everyone to follow the WeChat public account