问题描述
由于安装到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 (将#修改为@)