全新安装Python 3.9.0或任何其他方式修复没有名为'_ctypes'的模块错误

问题描述

由于安装到Python 3.9.0,因此无法将任何库安装到我的virtualenv。例如,当尝试通过pip安装库时,我得到:

$ pip3 install -r requirements.txt
Collecting anaconda==0.0.1.1
  Using cached anaconda-0.0.1.1.tar.gz (726 bytes)
    ERROR: Command errored out with exit status 1:
     command: /home/jack/dev/37/env/bin/python3 -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-01fhtisu/anaconda/setup.py'"'"'; __file__='"'"'/tmp/pip-install-01fhtisu/anaconda/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-b71dl332
         cwd: /tmp/pip-install-01fhtisu/anaconda/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>",line 1,in <module>
      File "/home/jack/dev/37/env/lib/python3.9/site-packages/setuptools/__init__.py",line 23,in <module>
        from setuptools.dist import distribution
      File "/home/jack/dev/37/env/lib/python3.9/site-packages/setuptools/dist.py",line 34,in <module>
        from setuptools import windows_support
      File "/home/jack/dev/37/env/lib/python3.9/site-packages/setuptools/windows_support.py",line 2,in <module>
        import ctypes
      File "/usr/local/lib/python3.9/ctypes/__init__.py",line 8,in <module>
        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.

我在一些地方看到应该通过安装libffi-dev然后重新安装python来解决此问题。例如:Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing

执行此操作的最佳方法是什么?我在Ubuntu 20.04上,在virtualenv请求python -V之外运行Python 3.9.0

为防止将来发生这种情况,通常建议仅在venv上仅在python(或任何其他语言)上安装较新版本,而不要在系统本身上安装新版本?

非常感谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...