centOS source installation python 3

First, check the current version of Python

python -V

  

Second, download and install the new package python

 

1, yum update source

yum update

 

2, the installation dependencies

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
 
 
 3, download the source code and compile and install python
wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
tar xvf Python-3.8.2.tgz 
cd Python-3.8.2
./configure --prefix=/usr/local/python3
make && make install

 

4, add a soft link

mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3/bin/python3 /usr/bin/python

 

In this way the system's default python version upgrade to python3 slightly

 

Guess you like

Origin www.cnblogs.com/zhouqingda/p/12636925.html