I know this question has been asked before but I can't find a solution that will work for me. I have uninstalled and reinstalled python serval times and changed the path location. Whenever I run python in cmd I get this error 'python' is not recognized as an internal or external command, operable program or batch file. Python will work in my Jupyter Notebook, but if I need to pip install something I am unable to do so.
1 Answer
Whenever I run
python
incmd
I get this error'python' is not recognized as an internal or external command, operable program or batch file
.
You need to add python.exe
to your Windows path variable(s). You can do this when installing Python with the official installer from python.org by selecting a custom installation and marking the correct option to add Python to your environment variables.
If you need to add the path to Python to your Windows path variable(s) manually (ex. because Python is already installed), look for the Windows Search and type env
into it. Click the first link indicating you wish to edit your environment variables.
If you are on Windows 7, add e.g.
;C:\path\to\python
to the end of yourPath
variable underSystem variables
, wherepython
is your Python installation folder (only usePATH
under your user variables if you want Python to be accessible by that user alone). If you click the wrong link in Windows Search, you may need to click theEnvironment Variables...
button to get to the settings described.On Windows 10, just add
C:\path\to\python
to the end of the list (in a new field).Do not add
python.exe
to your path entry (i.e.C:\path\to\python\python.exe
is wrong).
Python will work in my Jupyter Notebook, but if I need to
pip
install something I am unable to do so.
Adding Python to you environment variables through the official installer (above) should solve this. If not, you will need to perform the same (rough) steps above but add C:\path\to\python\Scripts
to your path (Scripts
is the folder where pip.exe
lives).
In either case, reboot your PC before attempting to access python
/pip
from the command line.
-
1Windows applies PATH additions automatically, on the fly, if added via the GUI, as soon as the Advanced Properties window is closed via OK and the terminal restarted– JW0914Nov 6, 2019 at 11:16
-
I have run into the issue (on Windows 7) where I have added something to the System
Path
and it will (apparently) be immediately available in some instances but not in others. Example: usingShift + Right-Click
andOpen command window here
will allow an item added to the SystemPath
variable to be immediately used. However, using the same steps from anExplorer
(file) window will yield'new_program' is not recognized as an internal or external command, operable program or batch file.
Nov 6, 2019 at 11:34 -