Pip can't find module pip._internal.utils

Viewed 1002

I did a fresh install of Python 3.8.3 for Windows 10. I can't get pip to work, it keeps complaining about module pip._internal.utils that can't be found.

When I run pip -v as a regular user, this is what I get:

Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\pip.exe\__main__.py", line 4, in <module>
  File "C:\Users\verhager\AppData\Roaming\Python\Python38\site-packages\pip\__init__.py", line 1, in <module>
    from pip._internal.utils.typing import MYPY_CHECK_RUNNING
  File "C:\Users\verhager\AppData\Roaming\Python\Python38\site-packages\pip\_internal\__init__.py", line 1, in <module>
    import pip._internal.utils.inject_securetransport  # noqa
ModuleNotFoundError: No module named 'pip._internal.utils'

I have tried reinstalling, rebooting, running as Administrator, reinstalling pip with get_pip.py, but nothing has worked sofar.

When searching, I found several people having similar issues on different OSes. It seems like I've tried all suggested solutions, but nothing has worked for me sofar.

3 Answers

Reinstalling didn't solve my problem. That is, not before I really made sure that nothing was left behind.

My Python install was in C:\Python38\. After uninstalling python, this directory remained and contained some left over modules, like pip. I manually deleted the whole C:\Python38 folder.

Then, I checked my AppData folder in my home dir. Everything in this folder and all subfolders that was related to Python or Python modules, I deleted as well. Keep in mind AppData is a hidden folder, so it you might have to enable showing of hidden files and folders in the explorer first.

Finally, I removed all Python folders from my PATH environment variables (system as well as user).

After that, I did a new install of Python 3.8 and everything works as expected.

What I think the problem was? Some left overs from a previously (broken) installation messed with my environment, causing pip not resolving required modules.

I had the same error as you, with Windows 10. I also investigated and found that the "pip._internal.utils" package was missing. I was able to overcome this issue without an extensive Cleanup/Reinstall of Python.

After ensuring the following

  • That the Python Binary and Scripts folders were part of %PATH%
  • That I was on a Console Window with Administrator privileges

I ran the following command

  • python -m ensurepip --default-pip

With this command the package was installed. I did a general verification of the installation with the following command.

  • pip --version

Which returned the with specs. This command invokes the missing package.

I faced the same issue and here's how I resolved this error on windows 7 -

  1. Navigate to C:\Users<user-name>\AppData\Roaming\Python\Python38\site-packages
  2. Delete pip folder

This is introduced when I read this messsage "You should consider upgrading via the 'python -m pip install --upgrade pip' comand." and followed using the same command for upgrading.

Related