CentOS 7.0
Python 3.8.0
報(bào)錯(cuò)
ERROR: Command errored out with exit status 1:
command: /root/.pyenv/versions/3.8.6/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-198v7rsw/virtualenvwrapper/setup.py'"'"'; __file__='"'"'/tmp/pip-install-198v7rsw/virtualenvwrapper/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-sxzcb4vn
cwd: /tmp/pip-install-198v7rsw/virtualenvwrapper/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/root/.pyenv/versions/3.8.6/lib/python3.8/site-packages/setuptools/__init__.py", line 23, in <module>
from setuptools.dist import Distribution
File "/root/.pyenv/versions/3.8.6/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/root/.pyenv/versions/3.8.6/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/root/.pyenv/versions/3.8.6/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
解決
yum install libffi-devel -y
ldconfig
原理
Python3中有個(gè)內(nèi)置模塊叫ctypes,它是Python3的外部函數(shù)庫(kù)模塊,它提供兼容C語(yǔ)言的數(shù)據(jù)類(lèi)型,并通過(guò)它調(diào)用Linux系統(tǒng)下的共享庫(kù)(Shared library),此模塊需要使用CentOS7系統(tǒng)中外部函數(shù)庫(kù)(Foreign function library)的開(kāi)發(fā)鏈接庫(kù)(頭文件和鏈接庫(kù))。由于在CentOS7系統(tǒng)中沒(méi)有安裝外部函數(shù)庫(kù)(libffi)的開(kāi)發(fā)鏈接庫(kù)軟件包,所以在安裝pip的時(shí)候就報(bào)了"ModuleNotFoundError: No module named '_ctypes'"的錯(cuò)誤