centos7 install python3.7 with problem and how to fix it.
问题如下:
configure: error: no acceptable C compiler found in $PATH 缺少gcc
zipimport.ZipImportError: can’t decompress data 缺少zlib,zlib-devel
No module named '_ctypes'
3.7版本需要一个新的包libffi-devel
yum install libffi-devel -y
解决如下:
yum install gcc zlib zlib-devel -y
yum install libffi-devel -y
有关openssl的修复,python找不到ssl模块 安装模块 yum install openssl-devel -y 去掉注视 # Socket module helper for socket(2) _socket socketmodule.c # Socket module helper for SSL support; you must comment out the other # socket line above, and possibly edit the SSL variable: SSL=/usr/local/ssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto
有关zlib的修复 1 到python安装目录下,运行./configure 2 编辑Modules/Setup文件 vim Modules/Setup 找到下面这句,去掉注释 #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
重新编译python3.7 ./configure --prefix=/usr/local/python3.7 make && make install
建立软连接:
ln -s /usr/local/python3.7/bin/python3 /usr/bin/python3 ln -s /usr/local/python3.7/bin/pip3 /usr/bin/pip3
效果:
顺便安装了Ipython:
pip3 install ipython #这里必须解决上面ssl模块的问题
ln -s /usr/local/python3.7/bin/ipython /usr/bin/ipython
因为缺少sqlite数据库模块,还有个报错:
/usr/local/python3.7/lib/python3.7/site-packages/IPython/core/history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved warn("IPython History requires SQLite, your history will not be saved")
解决方法:
yum install sqlite-devel -y
重新编译python3.7
这些坑相当头疼,所以提早把环境给装好
Ipython效果:
努力成为一个开发者
个人站点:www.pythonav.cn