How do I change my build configuration so that cmd

2020-04-10 00:47发布

问题:

When I try to run python or any language through Sublime Text 2, all it says is

[Error 2] The system cannot find the file specified
[cmd:  [u'python', u'-u', u'C:\\Users\\Owner\\Desktop\\RandomStuff\\python\\java\\bob.java']]
[dir:  C:\Users\Owner\Desktop\RandomStuff\python\java]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.7.0_03\bin]
[Finished]

I was told to change my build configuration so that the command prompt goes to the python interpreter, but changing the path environment variable does absolutely nothing except add

;C:\Python27\python

to the list. This is really frustrating because I am trying to make a game in Python and I have no idea how to fix this.

回答1:

The path is a list of directories, not files. You should add c:\Python27 to your path, not c:\Python27\python.



回答2:

After installing python from the following link http://www.python.org/download/releases/, you must Update your environment variables:

  1. click on start
  2. right click on computer
  3. click on advanced system settings
  4. click on environment
  5. locate path on system variables
  6. click on edit
  7. append ;C:\Python32\ to the end of the value or wherever the installer installed your Python

Make sure you restart sublime after doing this, you will still get an error if you didn't.



回答3:

The problem is related to the python command not being found in the exectuable path. You could point sublime explicitly to the python executable, or you could just fix the env path. The second is more important to have your general python set up properly.

C:\Python27\;C:\Python27\Scripts\

The first location contains python.exe and the second contains a "python" script that points back to the exe. This will allow a command using "python" to work.