CentOS7 system installs Python3.6.2 and coexists with Python2.7.5

888u

Last update at :2024-06-21,Edit by888u

Since the debugging and testing of the project software need to be run in the Python3 environment, the default CentOS7 system comes with the Python2.7.5 version, but some software needs to be run in the Python2.7 version, so in the current system You need to install an additional Python3.X version to support it, but you must also keep the original version.

Here Snail is trying to install and test in the test environment CentOS7 system. If we have friends who need to install and use it in their own production environment, they can either check whether it is feasible in the test system, or back up the data in the production environment. If there is a problem, it can be restored in time. Generally, snapshot backup is really more convenient. .

Articles about Python upgrades and problem solving:

1. Solve the problem of "zipimport.ZipImportError\\" error when compiling python on CentOS7

2. Method and process of upgrading Python2.6.6 to Python2.7.6 on CentOS6.x

3.9 Steps to upgrade the Python version of CentOS5 system to 2.7

First, detect the current version number

python -V

The current CentOS7 system defaults to python2.7.5 version.

Second, install the required software packages

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make -y

Enter the /usr/local/ directory and back up mv python python.bak.

Third, compile and install python3.x

yum install wget -ywget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xztar -xvJf Python-3.6.2.tar.xzcd Python-3.6. 2./configure prefix=/usr/local/python3make && make install

Compile and install version 3.6.2 here.

ln -s /usr/local/python3/bin/python3 /usr/bin/python

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip

Create a soft link. Then we execute python -V and we will see that it is version 3.6.

Third, modify the configuration file

Enter the /usr/bin/yum file, then replace python at the top with python2, save and exit.

Finally, we can execute python -V to see the python3.6.2 version, and python2 -V to see the original default 2.75 version.

Recommended site search: independent IP host, web page registration, Hong Kong vps host rental, personal free space, US vps host, free cn domain name registration, virtual host trial for 30 days, instant solution server, US proxy IP, server in the United States,

CentOS7 system installs Python3.6.2 and coexists with Python2.7.5

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码