关于centos7:20200323-Centos7下当前最高版本python392源码编译安装方法

4次阅读

共计 1601 个字符,预计需要花费 5 分钟才能阅读完成。

2020-03-23 Centos7 下以后最高版本 python3.9.2 源码编译装置办法

日期 作者 版本 备注
2021-03-22 dingbin V1.0

本文概要记录 Centos7 下 python3.9.2 源码编译装置办法。

  • 操作日期: 2021-03-23.
  • 操作环境:CentOS Linux release 7.5.1804,16 核 20G

具体操作办法如下:

  1. 官网下载以后最新最高版本 python release 包:Python-3.9.2.tar.xz
  2. 编译装置:
Python-3.9.2.tar.xz

tar xvf Python-3.9.2.tar.xz 

cd Python-3.9.2

./configure --prefix=/home/xx/app/python39 --enable-shared --enable-optimizations 
#留神:--enable-shared 十分重要,因为这个选项会编译出动静 python 链接库,供其余程序调用,比方编译 vim 大牛补全插件
YouCompleteMe 或 Vim 高版本时,就依赖动静 python 链接库。此时必须要加 --enable-shared 这个选项,否则 python 须要从新编译装置。make PROFILE_TASK="-m test.regrtest --pgo -j14"   -j14

make install

全副过程大概 10 分钟左右实现。

  1. 精要配置 python

     将 /home/xx/python39/ 退出~/.bashrc 中 PATH 环境变量
    cd /home/xx/python39/bin
    
    ln -sf pip3 pip
    ln -sf easy_install-3.9 easy_install3
    ln -sf easy_install-3.9 easy_install
    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
    
    保留退出。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
    保留退出。从新 source ~/.bashrc
    
    workon 能够看目前有哪些虚构 python 环境,workon xxx 进入某个虚构 python 环境
    mkvirtualenv -p ~/app/python39/bin/python --copies newvenv1 创立某个虚构 python 环境名叫 newvenv1
    deactivate 退出以后环境
    操作示例如下图所示:

正文完
 0