CentOS7.6 compile and install Python-3.7.4

installation steps

1. Download the installation package.
https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz wget
<description> If the message SSL / TSL error, plus --no-check-certificate option
2. Solutions compressed
tar-xzvf Python-3.7.4.tgz
cd Python-3.7.4
3. configuration
* View configuration options.
--help ./configure
* common configuration options to configure
the installation path --prefix = / usr / local / python3 #pyhton the
--with-openssl = / etc / pki / tls #OpenSSL library installation path
* If you want a includes all stable, optimized version construction activities, you can add the following options (but generally do not need this configuration check process will be very time-consuming)
--enable-optimizations
* check whether the system has OpenSSL installed
rpm -qa | grep -i openssl
* View version of OpenSSL
openssl version -a # will show the path to the installation of OpenSSL
* my installation configuration option
./configure --prefix = / usr / local / python3 --with-OpenSSL = / etc / pki / TLS
4. compile
the make
5. The installation
make install

Set Environment Variables

* Set soft links
LN /usr/local/python3/bin/python3.7 -s / usr / local / bin / Python
* modify / etc / profile, add the following:
Export the PATH = $ the PATH: / usr / local / python3 / bin
after saving, execute: Source / etc / Profile
* execute command to view the installed version
# --version Python
Python 3.7.4
* directly to run Python commands, detect whether the installation was successful
# Python
Python 3.7.4 (default, Sep 10 2019, 01:13:53)
[GCC 4.8.5 20,150,623 (Red Hat 4.8.5-36)] ON Linux
Type "Help", "Copyright", "Credits" or "License" for More Information.
>>>
# when the output the above information represents the Python-3.7.4 installed successfully.

Set pip tools

Python-3.7.4 version comes with pip tools, the installation is successful, there pip3 and pip3.7 two executable files in the installation path / usr / local / python3 / bin .
* Establish pip3 tool of soft link
ln -s / usr / local / python3 / bin / pip3 / usr / local / bin / pip3

Problems encountered in the installation process

1. ModuleNotFoundError: No module named '_ctypes '
the need to install the dependent libraries libffi-devel, execute the following command:
yum -y install libffi-devel # -y told all questions are answered yes

 

Guess you like

Origin www.cnblogs.com/yunfan1024/p/11495236.html