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

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 退出以后环境
    操作示例如下图所示:

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理