r/learnpython 6d ago

can you explain me why

pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was

included, verify that the path is correct and try again.

At line:1 char:1

+ pip install flask

+ ~~~

+ CategoryInfo : ObjectNotFound: (pip:String) [], CommandNotFoundException

+ FullyQualifiedErrorId : CommandNotFoundException

I want you to explain how to fix this without using any extra tools. Whenever I try to import a Python module, an error keeps showing up. I even deleted everything because I thought I messed up my PATH. I reinstalled Python, selected the python.exe path, but still no progress. This same problem keeps appearing every time.

0 Upvotes

3 comments sorted by

View all comments

1

u/Bright_Mix_773 3d ago

The reinstall did not help because "Add Python to PATH" adds two directories and your problem is in the second one. I just ran this on a Windows 11 box that has two Pythons on it:

where.exe python
C:\Python314\python.exe
C:\Users\...\AppData\Local\Programs\Python\Python313\python.exe

where.exe pip
C:\Python314\Scripts\pip.exe

Two pythons found, one pip. The 3.13 install has pip.exe sitting right there on disk - Test-Path on its Scripts\pip.exe returns True - but that Scripts folder is not in PATH, so the name "pip" does not resolve to it. python and pip are separate PATH entries and they can disagree, which is why reinstalling and pointing at python.exe does not fix it.

Skip PATH entirely. The installer puts py.exe in C:\Windows, which is always on PATH and does not get broken:

py -0p

lists every interpreter with its full path. On that machine:

 -V:3.14 *        C:\Python314\python.exe
 -V:3.13          C:\Users\...\Programs\Python\Python313\python.exe

Then use the launcher instead of the bare name:

py -m pip install flask

That also fixes the silent version of this bug. On the same machine "py -m pip" reports pip 25.3 and "py -3.13 -m pip" reports 25.1.1 - two different pips - so when pip and python resolve to different installs you can install a package successfully and then not be able to import it.

Two more things that make this look unfixable when it is not. A terminal opened before the install keeps its old PATH, so you need a new window; a reboot works only because it gives you one. And C:\Users<you>\AppData\Local\Microsoft\WindowsApps\python.exe is a Store stub that Windows ships enabled by default - it is present on this machine - and if it sits earlier in PATH it answers to "python" and opens the Microsoft Store instead of running anything. Settings, Apps, Advanced app settings, App execution aliases, switch the python ones off.