Domanda

I am trying to run a python file. I ve installed python 2.7.4. My code in .py file is just

import os 
print('hellp world')

However I am receiving as a message:

[Error 2] The system cannot find the file specified
[cmd:  [u'python', u'-u', u'C:\\Users\\user\\Desktop\\main.py']]
[dir:  C:\Users\...\Desktop]
[path: C:\Program Files.. ... ... ..., C:\Python27]
[Finished]

Any idea why the system doensnt recognize python file? In ENV path I have set the path of python.exe and in command prompt I ve tried the command python and I got the error python is not recognized as internal or external command.

È stato utile?

Soluzione

Maybe python is not in your %PATH%?

Quoting the python documentation

Besides using the automatically created start menu entry for the Python interpreter, you might want to start Python in the DOS prompt. To make this work, you need to set your %PATH% environment variable to include the directory of your Python distribution, delimited by a semicolon from other entries. An example variable could look like this (assuming the first two entries are Windows’ default):

C:\WINDOWS\system32;C:\WINDOWS;C:\Python27

Typing python on your command prompt will now fire up the Python interpreter. Thus, you can also execute your scripts with command line options, see Command line documentation.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top