3

When I try to install a python library with pip I got this error:

Traceback (most recent call last):
  File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python39\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

I heve also tryed to run py -3.9 -m pip install <library-name> but I got a similar error:

C:\Python39\python.exe: No module named pip

1 Answers1

12

Make sure you have added Python to Windows Environment Variable called PATH.

Then run python -m ensurepip

Alternative Solution:

Navigate to Python Scripts directory: (Example)

cd C:\Program Files\Python37\Scripts

and run easy_install.exe pip

  • 1
    "python - m ensurepip" -> "no module named ensurepip". "easy_install.exe pip" -> "...easy_install.exe not a recognized command... – lurker Aug 31 '22 at 17:44