python not in command line even though it is in path
Solution 1
This could be a duplicate answer, but the following steps has worked for me.
Note: This is in the case of Anaconda is installed instead of vanilla Python in Windows environment.
Under System variables:
- Create a variable
PYTHONHOME = C:\Users\username\Anaconda3
- Add the below 2 entries under PATH system variable:
%PYTHONHOME%
C:\Users\username\Anaconda3\Scripts
- Close the command prompt if opened earlier and try any python command (Note: no need to restart the OS):
example: python --version
output: Python 3.7.1
Hope this was useful. Cheers!
Solution 2
The python install directory on Windows should have the following files (ignore the pyscopg and pillow files):
Your PATH
environment variable should be like the below if you have install Python2 at the default location:
PATH=%PATH%;C:\Python27\;C:\Python27\Scripts\
You should also have the following in PATHEXT
:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
I noticed in your environment variables you have Python27\Scripts;
which is not correct. Try fixing that, and you'll have to close any command prompts if you change any environment variables. If the settings are as the above and you still can't run Python, do a re-install.
Solution 3
Lets assume that you installed python in the default location.
try adding this into your system environments.
name : PYTHONPATH
value: C:\Python27\;C:\Python27\Lib;C:\Python27\include;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\Lib\site-packages
Note: when you create a PYTHONPATH environment variable it might effect some other application to forcefully use this version of python instead their own.
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
When I type 'python' at the command line it says ''python' is not recognized as an internal or external command...'
I have Python in both User and System paths. In the past I have been able to run python from the command line, but suddenly today I can't.
I'm using Windows 7 32-bit.
Does anyone know what the problem could be?
Thanks
-
hbprotoss almost 11 years
echo %PATH%
What's the result? -
Admin almost 11 yearsC:\Python27;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;Python27\Scripts;C:\OpenSSL-Win32;
-
LF00 over 4 yearsRefer to this post
-
-
Admin almost 11 yearsI don't seem to have a python.exe file, only pythonw.exe. Is this the problem? It's not in my recycle bin so I haven't accidentally deleted it.
-
Philippe Schweitzer almost 11 yearsThe output is the same ''python' is not recognized as an internal or external command...'
-
janos almost 11 yearsI don't have a windows with me right now, but I'm pretty sure there should be a
python.exe
, and if you can't find it then something's wrong. Try to reinstall it. -
Saullo G. P. Castro almost 11 yearscould you check if you have
python.exe
inside this folderc:\Python27
-
Frank Osterfeld almost 11 yearsPYTHONPATH won't help with finding the python.exe executable.
-
DavidPostill almost 5 yearsPlease quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.
-
person27 over 3 yearsSeems to be paramount that Python37\Scripts\ is present. +1