简体   繁体   中英

Uninstalled wrapt module: Python not working

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM