Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python not recognized in Windows CMD even after adding to PATH

I'm trying to -learn to write and- run Python scripts on my Windows 7 64 bit machine. I installed Python in C:/Python34, and I added this to my Windows' PATH variable :

C:\Python34; C:\Python34\python.exe

(the second one is probably meaningless but I tried) and still I get this error in Windows command line :

C:\Users\me>python test.py
'python' is not recognized as an internal or external command,
operable program or batch file.

So how do I truly install Python on my Windows x64 machine ?

like image 710
jeff Avatar asked Jun 12 '14 14:06

jeff


People also ask

Why is CMD not recognizing Python?

The “Python is not recognized as an internal or external command” error is encountered in the command prompt of Windows. The error is caused when Python's executable file is not found in an environment variable as a result of the Python command in the Windows command prompt.

How do I enable Python in CMD?

To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!

Why does py work in cmd but not Python?

py is itself located in C:\Windows (which is always part of the PATH ), which is why you find it. When you installed Python, you didn't check the box to add it to your PATH , which is why it isn't there. In general, it's best to use the Windows Python Launcher, py.exe anyway, so this is no big deal.


2 Answers

This might be trivial, but have you tried closing your command line window and opening a new one? This is supposed to reload all the environment variables. Try typing

echo %PATH%

into the command prompt and see if you can find your Python directory there.

Also, the second part of your addition to the PATH environment variable is indeed unnecessary.

like image 196
yossim Avatar answered Oct 06 '22 10:10

yossim


I had the same problem: python not being recognized, with python in the path which was was not truncated.

Following the comment of eryksun in yossim's answer:

Also, if you installed for all users you should have %SystemRoot%\py.exe, which >is typically C:\Windows\py.exe. So without setting Python's directory in PATH >you can simply run py to start Python; if 2.x is installed use py -3 since >Python 2 is the default. – eryksun

I tried to use py instead of python and it worked. Meaning: python setup.py build -> does NOT work. py setup.py build -> does work. Hope it helps

like image 36
senis000 Avatar answered Oct 06 '22 10:10

senis000