Uninstalled wrapt module: Python not working

孤街浪徒 提交于 2021-01-28 06:03:55

问题


I was having difficulty installing a package because of a ModuleNotFoundError for wrapt and so I removed and tried to reinstall wrapt.

I ran the uninstall once, and wrapt was removed from one location. I tried to install, but the requirement was already satisfied, so I uninstalled wrapt again. See the three commands below:

Found existing installation: wrapt 1.12.1
Uninstalling wrapt-1.12.1:
  Would remove:
    c:\users\me\appdata\roaming\python\python38\site-packages\wrapt-1.12.1-py3.8.egg-info
    c:\users\me\appdata\roaming\python\python38\site-packages\wrapt\*
Proceed (y/n)? y
  Successfully uninstalled wrapt-1.12.1
PS C:\Users\me> pip install wrapt
Requirement already satisfied: wrapt in c:\users\me\appdata\local\programs\python\python38\lib\site-packages (1.12.1)
PS C:\Users\me> pip uninstall wrapt
Found existing installation: wrapt 1.12.1
Uninstalling wrapt-1.12.1:
  Would remove:
    c:\users\me\appdata\local\programs\python\python38\lib\site-packages\wrapt-1.12.1.dist-info\*
    c:\users\me\appdata\local\programs\python\python38\lib\site-packages\wrapt\*
Proceed (y/n)? y
  Successfully uninstalled wrapt-1.12.1

I thought I was all ready to start with a clean slate, but no such luck. Now I receive the following error whenever I try to run python or pip.

Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
  File "c:\users\me\appdata\local\programs\python\python38\lib\site.py", line 580, in <module>
    main()
  File "c:\users\me\appdata\local\programs\python\python38\lib\site.py", line 575, in main
    execusercustomize()
  File "c:\users\me\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\bootstrap.py", line 45, in _execusercustomize
    _register_bootstrap_functions()
  File "c:\users\me\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\me\appdata\local\programs\python\python38\lib\site-packages\certifi_win32\wrapt_certifi.py", line 3, in <module>
    import wrapt
ModuleNotFoundError: No module named 'wrapt'

I've tried finding installation for wrapt that does not use pip, but I haven't been successful. I also attempted upgrading Python from 3.8.1 to 3.8.3, which resulted in the same ModuleNotFoundError. Uninstalling Python and installing again yielded the same result. I currently cannot use my manually installed Python or pip at all.

What would you recommend?


回答1:


The solution was to use a second installation of Python (Anaconda) to fix my broken Python. My Anaconda Python maintains a separate set of installed packages, so it was still working. I opened an Anaconda prompt and ran (reference):

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

This reinstalled wrapt in the correct site-packages folder. My original Python is now working.

Lesson learned: be careful with pip uninstall



来源:https://stackoverflow.com/questions/62677593/uninstalled-wrapt-module-python-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!