Install Python3.7.2 and pip3 in centos/Linux service environment

LinuxServer systems generally MacOScome with a Python2development environment just like . Here I want to install a Python3development environment again as follows.

Install python3

The first step is to install dependencies

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel 

Step 2. Install gccthe compiler

yum install gcc -y

The third step is to install a libffi-develpackage, otherwise an error will be reported when compiling the source code package later.

yum install libffi-devel -y

Step 4. Enter the /usr/local/ directory

cd /usr/local/

Step 5: Find the corresponding development version. I use it here 3.7.2, so use the following command to download it directly:

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

Step 6: Unzip the downloaded file package:

tar -zxf Python-3.7.2.tgz

Step 7: Delete the compressed package after decompression is complete:

rm Python-3.7.2.tgz

Step 8. Change the directory Python-3.7.2 to Python3

mv Python-3.7.2 Python3

Step 9. Enter the python3 folder

cd python3

Step 10: Enter the following commands in order to compile and install the source code:

./configure --prefix=/usr/local/python3
make
make install

Step 11: Create a soft connection

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

After completing the above eleven steps in sequence, python3the installation is complete.

Enter python3to test:

Insert image description here
When you see this interface after entering this command, it means that python3the installation is complete.

Install pip3

The first step, installationsetuptools

python3Enter directly in the directory:

wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz

The second step, decompressionsetuptools

tar -zxvf setuptools-19.6.tar.gz

Part 3: Delete setuptoolsthe compressed package

rm setuptools-19.6.tar.gz

Step 4: Enter setuptoolsthe directory

cd setuptools-19.6/

Step 5: python3Compile through packaging

python3 setup.py build

Step 6: Install dependencies by executing the file

python3 setup.py install

Step 7: Create pip3a soft connection

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

Step 8. Check pip3the version of

pip3 -V

Insert image description here
What I installed here is currently the latest version. If it is the latest version, the installation is complete. If you find that it is not the latest version, just enter the update command:

pip3 install --upgrade pip

At this point, Python3the pip3complete installation is complete

Guess you like

Origin blog.csdn.net/weixin_43704471/article/details/85477388