【问题标题】:ModuleNotFoundError during pip install when module is actually installed实际安装模块时 pip install 期间的 ModuleNotFoundError
【发布时间】:2020-10-22 02:30:41
【问题描述】:

我尝试使用 pip install bentoml 安装 python 包 (BentoML),但收到以下错误,它给出了 ModuleNotFoundError: No module named 'wrapt'。但是,wrapt 模块实际上包含在我的site-packages 文件夹中,所以pip install wrapt 会导致我已经安装了wrapt 的消息。

我可以使用 pip 安装其他软件包,但 alembic 软件包会导致此问题。我能够使用我的 Anaconda Python 使用 pip 进行安装,但我希望它与这个 Python 版本一起安装。最好的前进方式是什么?

我在 Windows 10 设备上使用 Python 3.8.1。

  ERROR: Command errored out with exit status 1:
   command: 'c:\users\username\appdata\local\programs\python\python38\python.exe' 'c:\users\username\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\user~1.lastname\AppData\Local\Temp\tmpd30adik_'
       cwd: C:\Users\username\AppData\Local\Temp\pip-install-qers2adl\alembic
  Complete output (14 lines):
  Fatal Python error: init_import_size: Failed to import the site module
  Python runtime state: initialized
  Traceback (most recent call last):
    File "c:\users\username\appdata\local\programs\python\python38\lib\site.py", line 580, in <module>
      main()
    File "c:\users\username\appdata\local\programs\python\python38\lib\site.py", line 573, in main
      execsitecustomize()
    File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\bootstrap.py", line 37, in _execsitecustomize
      _register_bootstrap_functions()
    File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\bootstrap.py", line 25, in _register_bootstrap_functions
      from . import wrapt_certifi
    File "c:\users\username\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\wrapt_certifi.py", line 3, in <module>
      import wrapt
  ModuleNotFoundError: No module named 'wrapt'
  ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\username\appdata\local\programs\python\python38\python.exe' 'c:\users\username\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\user~1.lastname\AppData\Local\Temp\tmpd30adik_' Check the logs for full command output.

【问题讨论】:

  • 虽然我想出了一种安装wrapt的方法,但我仍然很好奇为什么Python在安装alembic包时找不到它。我认为这与安装两个 Python 版本的问题有关,但 wrapt 存在于正确的站点包目录中。任何线索都会有很大帮助!

标签: python pip modulenotfounderror wrapt


【解决方案1】:

使用其他版本的 Python 安装。打开 Anaconda 提示符(或同一设备上的其他 Python 版本),然后运行:

pip install alembic --target="c:\users\username\appdata\local\programs\python\python38\lib\site-packages"

这与我在尝试卸载/重新安装 wrapt 后破坏 Python 时使用的方法相同。另一个 Python 版本将 alembic 安装到正确的位置,并且原始安装工作正常。

【讨论】:

    猜你喜欢
    • 2018-02-06
    • 1970-01-01
    • 2019-11-07
    • 1970-01-01
    • 2021-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-21
    相关资源
    最近更新 更多