The date of The author version note
2021-03-22 dingbin V1.0

This article Outlines the compilation and installation of Python 3.9.2 source code under Centos7.

  • Operating date: 2021-03-23.
  • Operating environment: CentOS Linux Release 7.5.1804, 16 cores 20G

The specific operation method is as follows:

  1. Python-3.9.2.tar.xz: Python 3.9.2.tar.xz: Python 3.9.2.tar.xz
  2. Compile and install:
Xz tar XVF Python-3.9.2.tar.xz CD Python-3.9.2.tar.xz CD Python-3.9.2 #LDFLAGS=-rdynamic  export LDFLAGS=-rdynamic LDFLAGS=-rdynamic ./configure LDFLAGS=-rdynamic --prefix=/home/dingbin/app/python39 --enable-shared --enable-optimizations # --enable-shared is important because this option compiles a dynamic Python link library that can be called by other programs, such as YouCompleteme or Vim High, that rely on dynamic Python link libraries. You must add the --enable-shared option, or Python will need to recompile and install. make PROFILE_TASK=" -m test.regrtest --pgo -j14 " -j14 make install

The whole process takes about 10 minutes to complete.

3. Configure Python

PATH: CD /home/xx/python39/bin ln -sf pip3 PIP ln -sf easy_install-3.9 easy_install3: /home/xx/python39/bin ln -sf pip3 PIP ln -sf easy_install-3.9 easy_install3: /home/xx/python39/ Ln -sf python3.9 python vim ~/.pip/pip.conf  [global] timeout = 10000 index-url=http://pypi.douban.com/simple extra-index-url=http://mirrors.aliyun.com/pypi/simple/  #extra-index-url=https://pypi.tuna.tsinghua.edu.cn/simple/ #extra-index-url=http://pypi.mirrors.ustc.edu.cn/simple/ [install] trusted-host=pypi.douban.com #trusted-host=mirrors.aliyun.com #trusted-host=pypi.tuna.tsinghua.edu.cn #trusted-host=pypi.mirrors.ustc.edu.cn Save exit. PIP install virtualEnv virtualEnvWrapper PIP --upgrade install PIP vim ~/.bashrc:  export WORKON_HOME=${HOME}/.virtualenvs export PROJECT_HOME=${HOME}/work/projects/pythonprojects.git export VirtualEnvWrapper_python =${PYTHON39_HOME}/bin/python source ${PYTHON39_HOME}/bin/ virtualEnvWrapper.s Resource ~/.bashrc workon to see which virtual Python environments are currently available. MkVirtualEnv-p ~/app/python39/bin/python -- Copies of Copies An example of deactivate exiting the current environment is shown below: