Compile Python 3.7.4 with Centos6

Description

Suitable for CentOS6, CentOS7

Compile openssl

Download (here you need to check the minimum version of openssl required by python3.7 to compile)

$  wget http://www.openssl.org/source/openssl-1.1.1.tar.gz

· Compile

$ tar zxf openssl-1.1.1.tar.gz
$ cd openssl-1.1.1
$ ./config --prefix=$HOME/openssl shared zlib
$ make
$ make install

Compile Python 3.7.4

· Download package

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

· Unzip the package

$ tar zxf Python-3.7.4.tgz
$ cd Python-3.7.4

· Modify the configuration file-compile the SSL module

$ vi Modules/Setup
#SSL=/usr/local/sslSSL=/home/testerzhang/3rd/openssl
_ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto

Recommendation: 020 is continuously updated, the small circle of boutiques has new content every day, and the concentration of dry goods is extremely high.
There are everything you want to make connections and discuss technology!
Be the first to join the group and outperform your peers! (There is no fee for joining the group)
Click here to communicate and learn with Python developers.
Group number: 745895701
application and delivery :
Python software installation package, Python actual combat tutorial,
free collection of materials, including Python basic learning, advanced learning, crawling, artificial intelligence, automated operation and maintenance, automated testing, etc.

· Compilation method

$  ./configure --prefix=/home/testerzhang/3rd/Python-3.7.4 --with-openssl=/home/testerzhang/3rd/openssl 
$ export LD_LIBRARY_PATH=/home/testerzhang/3rd/openssl/lib/:$LD_LIBRARY_PATH
$ make
$ make install

· Migrate to other environments
Configure related dependent ssl library files so that if the system does not have this version of the ssl library during migration, you can read your own library files.

$ cp /home/testerzhang/3rd/openssl/lib/libssl.so.1.1 /home/testerzhang/3rd/Python-3.7.4/lib
$ cp /home/testerzhang/3rd/openssl/lib/libcrypto.so.1.1 /home/testerzhang/3rd/Python-3.7.4/lib

Configure python environment variables on other machines

$ vim ~/.bash_profile

export PYTHONHOME=$HOME/3rd/Python-3.7.4
export PYTHONPATH=$PYTHONHOME/lib/python3.7
export PYTHONUNBUFFERED=1


export PATH=$PYTHONHOME/bin:$PATH
export LD_LIBRARY_PATH=$PYTHONHOME/lib:$LD_LIBRARY_PATH

Validate environment variables of other machines

$ source ~/.bash_profile

verification

$ python3
Python 3.7.4 (default, Jan  7 2020, 11:10:45) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux
Type "help", "copyright", "credits" or "license" for more information.>>> import ssl

Guess you like

Origin blog.csdn.net/Python_xiaobang/article/details/112476908