美文网首页
virtualenvwrapperModuleNotFoundE

virtualenvwrapperModuleNotFoundE

作者: abelweiwencai | 来源:发表于2020-11-13 10:33 被阅读0次

    CentOS 7.0
    Python 3.8.0

    报错

    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中有个内置模块叫ctypes,它是Python3的外部函数库模块,它提供兼容C语言的数据类型,并通过它调用Linux系统下的共享库(Shared library),此模块需要使用CentOS7系统中外部函数库(Foreign function library)的开发链接库(头文件和链接库)。由于在CentOS7系统中没有安装外部函数库(libffi)的开发链接库软件包,所以在安装pip的时候就报了"ModuleNotFoundError: No module named '_ctypes'"的错误

    参考

    https://stackoverflow.com/questions/27022373/python3-importerror-no-module-named-ctypes-when-using-value-from-module-mul

    相关文章

      网友评论

          本文标题:virtualenvwrapperModuleNotFoundE

          本文链接:https://www.haomeiwen.com/subject/amrvbktx.html