label: Deepin,Python3, Compile Python3
Deepin is a Debian-based Linux distribution suitable for domestic use. Theoretically, the process of installing Python3 on Debian is also suitable for Deepin. All commands in this article are executed at root. Therefore, when not using the root account, you need to add sudo.
Install build tools and dependencies
apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl
Download Python 3.7.7 source code
curl -O https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tar.xz
If wget is installed, you can also use wget
Unzip, enter the directory, and execute the configuration before compilation
tar -xf Python-3.7.7.tar.xz
If you want to compile without replacing the original Python3, execute the following command.
make -j 8 && make altinstall
If you want to override the system's Python3, execute make install
This approach is risky for some Linux distributions, as long as you are already familiar with your Linux distribution.
make -j 8 && make install
Make soft link
mv /usr/bin/python3 /usr/bin/python.bak
ln -s /usr/local/bin/python3.7.7 /usr/bin/python3
mv /usr/bin/pip3 /usr/bin/pip.bak
ln -s /usr/local/bin/pip3.7 /usr/bin/pip3
The above two sets of commands are to backup the python3 and pip3 that come with the system first, but pip3 may not be installed on some systems, and an error will be reported when the third command is executed, which can be ignored. At the same time, when executing the above command, pay attention to the names of the python3 and pip3 files.
Python3 validation can be performed at this time