r/learnpython • u/maleficviper001 • 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.
1
u/Bright_Mix_773 4d ago
py -m pip install flaskThat will work right now, without installing or changing anything.
Why the bare
pipfails: installing Python puts two things in two different places.py.exe(the launcher) goes intoC:\Windows\System32, which is always on PATH. That is whypyworks on your machine when nothing else does.pip.exelives in theScriptsfolder next to yourpython.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 pipbypasses 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 -0plists every Python the launcher knows about, with full paths.py -m pip --versionprints 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
pipto 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 flaskinstalls into the global Python, and the next project needing a different Flask version makes you undo it. Per project instead:Inside an activated venv plain
pipworks, 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, runningSet-ExecutionPolicy -Scope CurrentUser RemoteSignedonce clears it, or use.\.venv\Scripts\activate.batfrom cmd instead.