django2.2升级:编译安装python3.7.3
一. 简介
Python 3.4 support has been deprecated. pip 19.1 will be the last one supporting it. Please upgrade your Python as Python 3.4 won't be maintained after March 2019 (cf PEP 429).
Python 3.4都快要退出舞台了,3.6估计也不远,后面最好还是用最新版本的python.
编译安装python3.7.3,这里记录下安装过程.
二. 安装
# 卸载yum安装的python3
yum -y remove python3*
# 安装编译依赖的包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
yum -y install readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum -y install libffi-devel
cd ~
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar zxvf Python-*.tgz
cd Python-*
./configure --prefix=/usr/local/python3
make
make install
# bin
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
# 动态库
# 同步修改/vps/save/install/common/conf/vps/bashrc
LD_LIBRARY_PATH=/usr/local/python3/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
ldconfig
# 删除临时文件
cd ~
rm -rf Python-*
rm -f Python-*.tgz
三.报错:ModuleNotFoundError: No module named '_ctypes'
之前安装的时候这个报错,是3.7版本需要一个新的包libffi-devel,要执行下面的命令
yum -y install libffi-devel
四.Fatal Python error: _PySys_BeginInit: can't initialize sys modul
./configure --enable-optimizations
编译有时会报错,可能是系统或者gcc的原因,编译的时候去掉--enable-optimizations就好了.
五. 结尾
最新版本的python,舒服...
参考: