问题复现:
编译安装Python3.7版本,在make install的时候,出现报错
zipimport.ZipImportError: can't decompress data; zlib not available make: *** [install] Error 1
解决方案:
yum install zlib*
问题复现2
File "/tmp/tmpnfe1bbxk/pip-9.0.3-py2.py3-none-any.whl/pip/__init__.py", line 45, in <module> File "/tmp/tmpnfe1bbxk/pip-9.0.3-py2.py3-none-any.whl/pip/vcs/mercurial.py", line 9, in <module> File "/tmp/tmpnfe1bbxk/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 36, in <module> File "/tmp/tmpnfe1bbxk/pip-9.0.3-py2.py3-none-any.whl/pip/utils/glibc.py", line 4, in <module> File "/home/wfq/soft/Python-3.7.0b3/Lib/ctypes/__init__.py", line 7, in <module>from _ctypes import Union, Structure, Array ModuleNotFoundError: No module named '_ctypes'make: *** [install] Error 1
解决方案:
#yum install libffi-devel -y#make install
编译成功 :
Looking in links: /tmp/tmpqi1x8_o_ Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-19.0.3 setuptools-40.8.0
问题原因:
python3中有个内置模块叫ctypes,它是python3的外部函数库模块,提供了兼容C语言的数据类型,并通过它调用Linux系统下的共享库(Shared library),此模块需要使用centos7系统中外部函数库(Foreign function library)的开发链接库(头文件和链接库)。
由于在centos7系统中没有安装外部函数库(libffi)的开发链接库软件包,所以在安装pip的时候就报了"ModuleNotFoundError: No module named ‘_ctypes’"的错误。
总结
新版本和旧版本有时候差别比较大,在安装的过程中一定要注意新旧版本的区别。多参考官方文档