2
C:\\Users\\HP\>pip
Traceback (most recent call last):
File "C:\\lib\\runpy.py", line 196, in \_run_module_as_main
return \_run_code(code, main_globals, None,
File "C:\\lib\\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\\Scripts\\pip.exe_main_.py", line 4, in \<module\>
ModuleNotFoundError: No module named 'pip'

Can you tell me how to solve this issue on Windows 11?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

0

Your Python distribution doesn't come with pip preinstalled. Try installing pip using these methods: https://pip.pypa.io/en/stable/installation/

For example, on Windows, you would run

py -m ensurepip --upgrade
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
SimonUnderwood
  • 469
  • 3
  • 12
  • If it "didn't come with it", then why is there a Python traceback when `pip` is ran from CMD? Clearly a `pip.exe` or `pip.bat` file exists to execute – OneCricketeer Apr 04 '23 at 17:51
  • @OneCricketeer Perhaps the way I phrased it was wrong, but either way, the pip module is not installed correctly in the Python distribution as evidenced by `No module named 'pip'`. – SimonUnderwood Apr 04 '23 at 17:56
  • I agree, but any Python 3.x installation for versions released in the last 9 years have come with pip – OneCricketeer Apr 04 '23 at 18:01
  • My mistake for phrasing it wrong. – SimonUnderwood Apr 04 '23 at 18:06
  • I run (py -m ensurepip --upgrade) this command and requirement already satisfied but still it can show No module named 'pip' – Aditya Uparkar Apr 04 '23 at 18:13
  • 1
    @AdityaUparkar try the other options within the link. The few times I've encountered the issue, copying and running `get-pip.py` is the most reliable fix for me. – SimonUnderwood Apr 04 '23 at 18:16
  • @AdityaUparkar Or, you can try to use `pipx` and `poetry` to properly install Python packages in a "virtual environment", which isolates you downloading Python libraries into your OS. https://python-poetry.org/docs/#installing-with-pipx – OneCricketeer Apr 04 '23 at 18:30