hello. i downloaded the latest version of python from python.prg and tried checking if pip is on my system using the command prompt but it is saying " ‘pip’ is not recognized as an internal or external command, operable program or batch file." i have tried uninstalling and re-installing but it is not working. i ticked both boxes available when installing and yet still the cmd did not confirm pip. i have tried most of the solutions i found online like going to advanced system settings and then environmental variables. edit. click on new and paste the copied address from the cmd and yet nothing. i have tried to instal pip buy still not working please what do i do? please help me
Make a virtualenv and use pip from it. There’s also ensurepip in CPython, but it’s global so I don’t recommend using it directly.
We need to understand:
-
Exactly what installations of Python are currently on the system?
-
Which one do you want Pip to install for (at least, this time)?
-
What is currently on the
PATH
?
If you want to keep trying to solve it yourself, please read:
Since you mentioned batch files, I assume you are on windows. You can also try python -m pip
, provided Python is actually in your $PATH
. Any command you type in, is located through scanning the directories in that environment variable, on any OS. So unless it’s there, it won’t be found. If you know where it is, though, you can use full a full file path to invoke it.
Also, check these documents to see if they can solve your mystery:
Yes pip is there but the path on my Windows wasn’t set up to find it. Add these 3 directories to your path variable:
- c:\users\USERNAME\AppData\Local\Programs\Python\Python39
- c:\users\USERNAME\AppData\Local\Programs\Python\Python39\scripts
- c:\users\USERNAME\AppData\Local\Programs\Python\Python39\lib
Modify for your installation. Basically Python\Python39
is your root director for Python, so pip is under Python\Python39\Scripts
I believe.
A recent Windows update gives us the where
command to find a file in a cmd.exe window. Use it like this: where pip.exe
.
I have a shortcut to run cmd.exe and it runs c:\addpath.bat which contains paths to Python and other variables. Right click the shortcut, click Properties. Go to the Shortcut tab. In the Target field should be something like this: C:\Windows\System32\cmd.exe /k c:\addpath.bat
/k runs the cmd.exe window but keeps the window open after running addpath.bat. Otherwise the cmd window will close after running addpath.bat.
The 39
part will depend on what version was installed, of course.
As far as I know, where
doesn’t search for anything. It only says what path will be used if you try running the command.
This is what virtual environments are for.
On Windows, it’s recommended that you use the Python Launcher py
:
py -m pip install something
Thank you for responding. i went to the environment variables and added the directories you listed out but pip is still not showing in the cmd. i tried the where pip.exe and it showed me the place it is located but i don’t know how to moved on from there.
See MRAB’s recommendation to use py
command.
Its far easier then messing with PATH on Windows.
This is correct, but when I first made my path for my cmd.exe window it did not include c:\windows, which is where py.exe is. After the path was fixed py worked.
NOTE: py.exe seems to be updated to use the most recent version of python.exe that is installed the latest. Is this true?
By default py.exe picks the highest version of python that is installed.
You can change this with the py.ini config file that is documented here 4. Using Python on Windows — Python 3.12.2 documentation
*[quote=“Matthew Barnett, post:8, topic:47042, full:true, username:MRAB”]
On Windows, it’s recommended that you use the Python Launcher py
:
py -m pip install something
*this was what was shown to me when I put in the command in cmd. I don’t know what to do
Type py
not python
!
The third one is correct, and you can see that it is working because when you try to use Pip to install Pip, Pip correctly tells you that Pip is already installed (that’s how you could use it!).
The others are not what you were told to type, so of course they don’t do the right thing.
You cannot “install Pip” here because you already have it installed.
Even if you could, that would not make pip
work as a command.
The reason that pip
does not work as a command has nothing to do with installing it.
The reason that pip
does not work as a command is because of how the PATH
environment variable works.
Please go back and read the links I gave you in my first reply.