ModuleNotFoundError: No module named '_ctypes' ERROR:Command errored out with exit status 1: python

Ubuntu下载 nginx 时报错:

    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-7e0xdb36/uwsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-7e0xdb36/uwsgi/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-install-7e0xdb36/uwsgi/pip-egg-info
         cwd: /tmp/pip-install-7e0xdb36/uwsgi/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "", line 1, in 
      File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 20, in 
        from setuptools.dist import Distribution, Feature
      File "/usr/local/lib/python3.7/site-packages/setuptools/dist.py", line 36, in 
        from setuptools import windows_support
      File "/usr/local/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in 
        import ctypes
      File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in 
        from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决办法:下载下面这些库,重新编译python源文件(make altinstall)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus
sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev
sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev
sudo apt-get install libssl-dev openssl
sudo apt-get install libffi-dev

原因:

其实在一开始下载 python3.7 进行编译时,就报了上面类似的错,但当时发现3.7已经能用了,就没管,但苍天饶过谁,最后花了好长时间才解决.


参考

你可能感兴趣的:(踩坑)