CentOS7 compiled mounted Python3.7.x effective pro-test []

  • All operations are operating under the root user

  • Download the installation package

  • Compile and install

  • Softlinks

  • verification

installation:

Update yum:

yum update

Python installed dependence:

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel zlib-devel ncurses-devel tk-devel libffi-devel gcc make

Download python installation package: it is installed is Python3.7.4 due to the possible change may cause the download URL wget fails, we recommend the following URL to open select the desired version and then right to copy the required version of links using wget

# Do not specify a default download directory 
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
# downloaded to the specified file directory / Home / Apps
wget -P / Home / Apps / https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
# recommended to specify the downloaded file directory, easy to manage, you can choose a top shell command

Decompression:

cd into the archive just downloaded the file directory, unzip the file

tar -zxvf Python-3.7.4.tgz

Into the folder:

cd Python-3.7.4

Create the installation directory:

Note: All operations completed by the root authority

mkdir /usr/local/python3

Specify the installation path:

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

Compile and install:

make && make install

Note: If an error occurs, try to make and install gcc, followed by the implementation:

yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++

After the completion of re-compile installation operations: Successfully installed display terminal performs a complete compilation represents a successful installation, otherwise self-checking error in accordance with the error message, every step of the operation were successful before continuing to the next step.

make && make install

Replace the system default python older versions of python backup system

mv /usr/bin/python /usr/bin/python2.7.5

Add soft link:

Add soft or added to the environment variables, you can use the direct input of the python

ln -s / usr / local / python3 / bin / python3 / usr / bin / python # Create a soft link to python3 
LN -s / usr / local / python3 / bin / pip3 / usr / bin / pip3 # Create a soft link to pip3

verification:

[root@virtual] python -V 
Python 3.7.4
[root@virtual] pip3 -V
pip 19.0.3 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
[root@virtual] python
Python 3.7.4 (default, Oct 4 2019, 18:59:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Complete!

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/Liuyt-61/p/11621773.html