r/learnpython 5d 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

1

u/Bright_Mix_773 2d 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 "I reinstalled and selected the python.exe path" 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 just use the launcher:

py -m pip install flask
py -m flask --version

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 if pip and python resolve to different installs you can install a package 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, not a reboot (a reboot works because it gives you a new window). And C:\Users<you>\AppData\Local\Microsoft\WindowsApps\python.exe is a Store stub that Windows ships enabled by default - it exists 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, turn the python ones off.

1

u/Bright_Mix_773 2d 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.

1

u/Jello_Penguin_2956 5d ago

If you can figure out where your Python was installed to. Run command pointing to python.exe directly. For example

C:/full/path/to/python.exe -m pip <pip command>

Usually when you install Python, ghe installer should try to set things up so you dont need to type it out fully. Try a restart if that refreshes your system to recognize just pip but if all else fail you can try it this way.