问题
I tried installing a python package (BentoML) using pip install bentoml
, and I received the following error, which gives a ModuleNotFoundError: No module named 'wrapt'
. However, the wrapt
module is actually included in my site-packages
folder, so a pip install wrapt
results in the message that I already have wrapt
installed.
I can install other packages using pip, but the alembic
package causes this issue. I was able to install using pip using my Anaconda Python, but I want it installed with this Python version. What is the best way forward?
I'm using Python 3.8.1 on a Windows 10 device.
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.
回答1:
Install using another version of Python. Open up an Anaconda prompt (or another version of Python on the same device), and run:
pip install alembic --target="c:\users\username\appdata\local\programs\python\python38\lib\site-packages"
This was the same approach I used when I broke Python after trying to uninstall/reinstall wrapt. The other Python version installs alembic to the correct location and the original install works.
来源:https://stackoverflow.com/questions/62680281/modulenotfounderror-during-pip-install-when-module-is-actually-installed