I am a newbie in Python and had a problem with installing Python packages on my windows computer. I installed Python itself and then had to install the packages "Numpy" and "Matplotlib" as well. My teacher told us to do it with the commands:
python -m pip install --upgrade pip
pip install numpy
pip install matplotlib
I managed to install Python but when I run the first command to install pip I got the error message telling me that Python is not found. I found the command py -m pip --version here and it worked. After running it pip got installed and I got the message "pip 22.3 from C:\Users\Kaja\Programs\Python\Python310\lib\site-packages\pip (python 3.10)". I guessed this message means that its working.
I had a similar problem with the commands to install Numpy and Matplotlib. It only worked with this commands
py -m pip install numpy
py -m pip install matplotlib
I searched the internet and found this question telling me to run the command doskey py=python and it did not work. But when I swapped py and python so that the command was doskey python=py I eventually could run my teachers commands.
I checked the windows documentation and they are using the same commands as my teacher. I am very curious to know why I had this problem because on my fellow students computers it worked without the doskey command.
Edit:
Thank you very much @RustyPython. I checked my environment variables and the path to the python.exe was already there. Out of curiousity I deleted the python.exe from the path variable and although I did that the commands still worked! Another thing I tried was to remove the doskey macro like discribed in this article but still the commands still run without any errors. I think its something else.
py's job is to dispatch to Python interpreters, so one can have several different versions of Python installed on a system and letpylook up the location of the one that's requested at any particular invocation time. It's entirely appropriate, given that that task, that it (and not one of those individual interpreters) be in the global PATH.#!/usr/bin/env python35vs#!/usr/bin/env python39to let scripts choose their own interpreters; a.pyextension can only be associated with one thing. The goal of py.exe is to be that one universal thing that's then responsible for starting Python 3.5 for scripts written for that version, vs Python 3.9 for scripts written for that version, etc. See peps.python.org/pep-0397, the proposal that led topy.exe's initial creation.