3

so I have recently gotten into python and I use sublime text 2 alot for things like HTML and CSS and I want to use it for python too but when i try to compile with it I get the following error:

[Error 2] The system cannot find the file specified [cmd: [u'python', u'-u', u'C:\\Users\\User\\AppData\\Roaming\\Sublime Text 2\\Projects\\All Python Coding stuff\\Sublime Testing.py']] [dir: C:\Users\User\AppData\Roaming\Sublime Text 2\Projects\All Python Coding stuff] [path: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Panda Security\WaAgent\Common;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.7.0_51\bin] [Finished]

I have changed the build system to python and I have restarted and even installed python again. When I run a python script in IDLE it works fine.

Edit 1.

So now i get the error:

[Error 2] The system cannot find the file specified [cmd: [u'python', u'-u', u'C:\\Users\\Weber\\AppData\\Roaming\\Sublime Text 2\\Projects\\All Python Coding stuff\\Sublime Testing.py']] [dir: C:\Users\Weber\AppData\Roaming\Sublime Text 2\Projects\All Python Coding stuff] [path: /usr/local/bin] [Finished]

my `python.sublime-build' looks like this:

{
"cmd": ["python", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
6
  • Have you added the python executable directory to your system's path environment variable? Commented Mar 17, 2014 at 23:49
  • No I have not. Or at least I don't think I have. Commented Mar 18, 2014 at 0:05
  • How can I go about doing that? Commented Mar 18, 2014 at 0:12
  • For the record, you don't compile Python code as a separate step (unlike languages such as C++, Java, or C#). The runtime compiles it on the fly. You just run your program. Commented Mar 18, 2014 at 0:19
  • Ok thanks for the clarification, I knew it was something like that i just didn't know what else to call it. Commented Mar 18, 2014 at 0:32

2 Answers 2

4

You need to add the python directory to your system's path environment variabe. To do that in windows you need go to Control Panel> System and Security > System > Advanced System Settings> in the advanced tab go to Environment Variables. In the environment variables in the System Variables area scroll down until you find Path. Select it and press Edit. Then a window should appear titled Edit System Variable where you have the variable name (should be path) and the variable value which is a long string. At the start of the string you need to manually add the python's directory. For example my python 2.7 directory is at *C:\Python27* So you need to add C:\Python27\ at the start of the string. So after you do that the value should now look something like that:

C:\Python27\;C:\Program Files etc..

Try that and tell us the results :)

Hope that helped

Cheers, Alex

Sign up to request clarification or add additional context in comments.

1 Comment

What if I have two python versions (32bit, 64bit) and want to make build systems for both?
1

It happens for the reason that the cmd starts at "C:\Users\YOU". You have to "say" the complete path. I send the args "-u" and the my file's url directly to the python.exe.

Try it:

{
"cmd": ["C:\\Python27\\python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

Obs: I'm using Python 2.7 and its executable file is in C:\Python27\ folder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.