1. 程式人生 > >centos 7 編譯 python3.7.0

centos 7 編譯 python3.7.0

str error module error: ctu err pro init lin

安裝編譯所需庫
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即可

centos 7 編譯 python3.7.0