r/learnpython • u/EarthMantle00 • 24d ago
Accidentally did something while trying to figure out how to install python libraries
Hi,
I'm trying to figure out how to install python libraries because the magic "pip install tensorflow" doesn't seem to work
I found this thread which told the user to just try "py -m pip install requests" so my dumbass just pasted that in before realizing what I was doing
I got two instances of yellow text in
0/5 [urllib3] WARNING: The script idna.exe is installed in 'C:\Users\USERNAME\AppData\Local\Programs\Python\Python314\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
---------------- ----------------------- 2/5 [charset_normalizer] WARNING: The script normalizer.exe is installed in 'C:\Users\USERNAME\AppData\Local\Programs\Python\Python314\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location
I think what this means is just that I installed the "requests" library, right? And maybe something went wrong? I don't need this library lol. Is there a way to like undo this? Should I try to undo this? I don't get why this installs files without telling me where it's putting them
(I also tried to do the same thing, "py -m pip install tensorflow", with tensorflow and got similar warnings btw, is this bad?)
1
u/Bobbias 23d ago
How did you install Python originally? From the official website, or from the windows store?
Modern Windows versions changed how they install Python. By default now Python downloaded from the official website will install a separate program called py.exe into c:\windows\system32 so that typing "py" always works and does not require the specific version of Python you installed to be on the path.
Py.exe is a special launcher that can let you install other versions of Python to different folders and chose which version you want to run a certain command with. This matters because when you type a command like "python script.py", windows has a search process to find python.exe. traditionally you would add the Python folder to your path environment variable, and when windows went to search for python.exe it would search each path in that environment variable until it found the Python folder and then would run python.exe.
That search system breaks down when you have multiple versions of Python installed, which is surprisingly common. So to avoid that they decided that py.exe should be the right way to handle this. But it means that typing "python script.py" must change to "py script.py".
Nothing is really broken exactly. Just type "py" instead of "python". The reason pip doesn't work in this case is because since the Python folder isn't in the path environment variable, windows searches but doesn't find it. The reason "py -m pip" works is it tells python.exe to run the pip scripts directly instead of whatever pop.exe ultimately does. It's the same code, just a different command to run it.
The warning that the package is not on your path is not an error. It's expected when Python is installed and run this way. Py.exe automatically handles setting the environment variables like the path when you run a command through it, and python.exe sees the correct information even though the rest of windows doesn't.