在Sublime Text 2中运行python得到错误 [英] Running python in Sublime Text 2 getting error

查看:770
本文介绍了在Sublime Text 2中运行python得到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我最近进入了python,我使用sublime文本2 alot的东西像HTML和CSS,我想使用它的python太,但是当我试图编译它,我得到以下错误:

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:


[错误2]系统找不到指定的档案
[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]
[已完成]

我已经将构建系统更改为python,我已经重新启动,甚至再次安装python。当我在IDLE中运行python脚本时,它工作正常。

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.

编辑1。

错误:


[错误2]系统找不到指定的文件
[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]
[完成]

my`python.sublime -build'看起来像这样:

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

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


推荐答案

p>您需要将python目录添加到系统的路径环境变量。
要在Windows中执行此操作,您需要转到控制面板>系统和安全>系统>高级系统设置>高级选项卡中的环境变量。在系统变量区域中的环境变量中,向下滚动,直到找到路径。选择它,然后按编辑。然后出现一个名为编辑系统变量的窗口,其中包含变量名(应为路径)和变量值(长字符串)。在字符串的开头,你需要手动添加python的目录。例如我的python 2.7目录是在* C:\Python27 * 所以你需要在字符串的开头添加C:\Python27 \。所以在你这样做后,值现在应该是这样:

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 等。

尝试一下并告诉我们结果:)

Try that and tell us the results :)

帮助

干杯,
Alex

Cheers, Alex

这篇关于在Sublime Text 2中运行python得到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆