安装编译所需库
yum install -y libffi-devel
编译安装
cd /usr/local/src
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar zxf Python-3.7.0.tgz
cd Python-3.7.0
./configure --prefix=/usr/local/python370
make && make install
若修改默认python,yum会出问题,故添加环境变量PATH
不能修改默认
unlink /usr/bin/python
ln -s /usr/local/python370/bin/python3 /usr/bin/python
/etc/profile添加PATH
PATH=$PATH:/usr/local/python370/bin
注意
报错
File "/usr/local/src/Python-3.7.0/Lib/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
make: *** [install] Error 1
安装libffi-devel即可