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
具体操作办法如下:
- 官网下载以后最新最高版本python release包:Python-3.9.2.tar.xz
- 编译装置:
Python-3.9.2.tar.xztar 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 " -j14make install
全副过程大概10分钟左右实现。
精要配置python
将/home/xx/python39/ 退出~/.bashrc 中PATH环境变量cd /home/xx/python39/binln -sf pip3 pipln -sf easy_install-3.9 easy_install3ln -sf easy_install-3.9 easy_installln -sf python3.9 pythonvim ~/.pip/pip.conf退出如下内容:[global]timeout = 10000index-url=http://pypi.douban.com/simpleextra-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 virtualenvwrapperpip --upgrade install pipvim ~/.bashrc 退出:export WORKON_HOME=${HOME}/.virtualenvsexport PROJECT_HOME=${HOME}/work/projects/pythonprojects.gitexport VIRTUALENVWRAPPER_PYTHON=${PYTHON39_HOME}/bin/pythonsource ${PYTHON39_HOME}/bin/virtualenvwrapper.s保留退出。从新source ~/.bashrcworkon 能够看目前有哪些虚构python环境,workon xxx 进入某个虚构python环境mkvirtualenv -p ~/app/python39/bin/python --copies newvenv1 创立某个虚构python环境名叫newvenv1deactivate 退出以后环境操作示例如下图所示: