1

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.

2

1 Answer 1

1

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.

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.

add Python to your environment variables - screenshot

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 your Path variable under System variables, where python is your Python installation folder (only use PATH 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 the Environment 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.

3
  • 1
    Windows 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
    – JW0914
    Nov 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: using Shift + Right-Click and Open command window here will allow an item added to the System Path variable to be immediately used. However, using the same steps from an Explorer (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
  • In case it helps, I use ConEmu and an updated PATH will not apply until all instances of ConEmu have been closed and ConEmu restarted. I'm not sure how the native PowerShell and command terminals deal with PATH changes, but it may be in a similar way
    – JW0914
    Nov 6, 2019 at 11:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .