0

我试图在我的 ubuntu 18.04 电脑上使用 python 3.8.6 创建的虚拟环境中empy使用pip3 install empy命令安装,但出现以下主要错误:

ERROR: Could not find a version that satisfies the requirement empy (from versions: 3.3.2, 3.3.4)
ERROR: No matching distribution found for empy 

我还安装了“libffi-dev”sudo apt-get install libffi-dev来防止错误ModuleNotFoundError: No module named '_ctypes',但错误仍然存​​在并且保持不变。

终端中的完整错误:

(py3venv) expert-bot@expert-nx:~/python3_ws$ pip3 install empy
Collecting empy
  Using cached empy-3.3.4.tar.gz (62 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/expert-bot/python3_ws/py3venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-04mt1wt_/empy_f5b8490ded264bce82e92de860ffaccf/setup.py'"'"'; file__='"'"'/tmp/pip-install-04mt1wt_/empy_f5b8490ded264bce82e92de860ffaccf/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-vx6cf784
       cwd: /tmp/pip-install-04mt1wt_/empy_f5b8490ded264bce82e92de860ffaccf/
  Complete output (13 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/setuptools/__init__.py", line 18, in <module>
      from setuptools.dist import Distribution
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/_virtualenv.py", line 89, in exec_module
      old(module)
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/setuptools/dist.py", line 37, in <module>
      from setuptools import windows_support
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
      import ctypes
    File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
      from _ctypes import Union, Structure, Array
  ModuleNotFoundError: No module named '_ctypes'
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/3b/95/88ed47cb7da88569a78b7d6fb9420298df7e99997810c844a924d96d3c08/empy-3.3.4.tar.gz#sha256=73ac49785b601479df4ea18a7c79bc1304a8a7c34c02b9472cf1206ae88f01b3 (from https://pypi.org/simple/empy/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached empy-3.3.2.tar.gz (138 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/expert-bot/python3_ws/py3venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-04mt1wt_/empy_104fd15b7f9e408eb4a702d46fe5de03/setup.py'"'"'; file__='"'"'/tmp/pip-install-04mt1wt_/empy_104fd15b7f9e408eb4a702d46fe5de03/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-_fwmqok0
       cwd: /tmp/pip-install-04mt1wt_/empy_104fd15b7f9e408eb4a702d46fe5de03/
  Complete output (13 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/setuptools/__init__.py", line 18, in <module>
      from setuptools.dist import Distribution
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/_virtualenv.py", line 89, in exec_module
      old(module)
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/setuptools/dist.py", line 37, in <module>
      from setuptools import windows_support
    File "/home/expert-bot/python3_ws/py3venv/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
      import ctypes
    File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
      from _ctypes import Union, Structure, Array
  ModuleNotFoundError: No module named '_ctypes'
  ----------------------------------------
WARNING: Discarding
https://files.pythonhosted.org/packages/b7/56/72a285d257c7791616960493a04f14c05ca1bf7a83dd208485cf991563bd/empy-3.3.2.tar.gz#sha256=99f016af2770c48ab57a65df7aae251360dc69a1514c15851458a71d4ddfea9c (from https://pypi.org/simple/empy/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement empy (from versions: 3.3.2, 3.3.4)
ERROR: No matching distribution found for empy 

这个问题的可能解决方案是什么?

4

1 回答 1

0

看起来您的 Python 缺少该_ctypes模块,但我认为empy之后会安装。我相信_ctypes(取决于 libffi)在安装 Python 本身时已内置到 Python 中。如果您自己安装了 Python,然后安装了 libffi,请尝试重新安装 Python。它甚至会在终端中写入它构建的“可选”模块,这里_ctypes应该是其中之一。

哦,如果 Pythonconfigure脚本很难找到 libffi,请提供--with-system-ffi并将 libffiinclude目录添加到CPPFLAGS,并将 libffilib目录添加到LDFLAGSand LD_LIBRARY_PATH,例如

export CPPFLAGS="-I/path/to/libffi/include ${CPPFLAGS}"
export LDFLAGS="-L/path/to/libffi/lib -Wl,-rpath=/path/to/libffi/lib ${LDFLAGS}"
export LD_LIBRARY_PATH="/path/to/libffi/lib:${LD_LIBRARY_PATH}"
 ./configure --with-system-ffi ...
于 2022-01-26T22:50:37.333 回答