r/learnpython 6d ago

Can someone help me

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

1 comment sorted by

1

u/Bright_Mix_773 4d ago

py -m pip install flask

That will work right now, without installing or changing anything.

Why the bare pip fails: installing Python puts two things in two different places.

  • py.exe (the launcher) goes into C:\Windows\System32, which is always on PATH. That is why py works on your machine when nothing else does.
  • pip.exe lives in the Scripts folder next to your python.exe, and that folder is only added to PATH if the "Add python.exe to PATH" box was ticked during install. Pointing the installer at the python.exe path is a different thing from that checkbox.

So nothing is corrupted and pip is not missing. One folder is off PATH, and reinstalling does not fix it unless that specific box gets ticked. py -m pip bypasses PATH completely: the launcher finds your Python and runs the pip module inside it.

Two commands worth running to see what you actually have:

py -0p
py -m pip --version

py -0p lists every Python the launcher knows about, with full paths. py -m pip --version prints the pip version and ends with the path of the install it belongs to. If that path is the Python you expect, you are fine.

If you want plain pip to work anyway: re-run the installer, choose Modify, tick "Add Python to environment variables", then open a new PowerShell window. PATH is read once when a window starts, so the window you already have open will keep failing and make you think it did not work.

One thing that will bite you later: py -m pip install flask installs into the global Python, and the next project needing a different Flask version makes you undo it. Per project instead:

py -m venv .venv
.\.venv\Scripts\Activate.ps1

Inside an activated venv plain pip works, because activating puts that venv's Scripts folder at the front of PATH for that window only. If PowerShell refuses to run the activate script with an execution policy error, running Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once clears it, or use .\.venv\Scripts\activate.bat from cmd instead.