How to install Python 3 independently under CentOS 7

Time:2021-4-13

1、 Deployment preparation

Inspection and installation of deployment environment tools

1) Install the EPEL release Library in case the DB4 devel dependency installation fails

 

 yum -y install epel-release

 

 

  2)Install external function library(libffi)

 yum -y install libffi-devel

 

 

  3)Install compile environment dependencies(all must be installed successfully, otherwise compilation will fail)

 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

 

 

  4)installgcc

 yum -y install gcc

 

  

  5)installrz

 

 yum -y install lrzsz

 

 

2Python installation and configuration

Python installation and python environment variable configuration

1) RZ choose to upload the tgz installation package of python3. X

 rz

 

It’s herePython3.7.1Version, upload python-3.7.1.tgz.

 

  2)useTar command decompresses python-3.7.1.tgz

 tar -zxvf Python-3.7.1.tgz

 

 

  3)Switch toPython-3.7.1 directory

 cd Python-3.7.1

 

 

useConfigure sets / usr / local / python3 as the installation directory

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

 

 

  4)Compile and installMake & & make install

 make && make install

 

  

  5)establishThe soft connection between python3 and PIP3

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

 

 

  6)take/Add usr / local / python3 / bin to the path variable

 vim ~/.bash_profile

 

  #python path

  echo export PYTHON_PATH=/usr/local/python3

  echo PATH=$PYTHON_PATH/bin:$PATH

 

After modificationSource to make the variable work.

 source ~/.bash_profile

 

  7)inspectIs python3.7.1 installed and can python2 run

 python3

 

Exit() # exit from Python 3

 

 python2

 

 exit()

 

thus, python3 installation complete.

Recommended Today

Deeply analyze the principle and practice of RSA key

1、 Preface After experiencing many dark moments in life, when you read this article, you will regret and even be angry: why didn’t you write this article earlier?! Your darkest moments include: 1. Your project needs to be connected with the bank, and the other party needs you to provide an encryption certificate. You have […]