简体   繁体   English

Python Sublime文字路径

[英]Python Sublime Text Path

I downloaded sublime text 2 and I have a problem running a code with the language python. 我下载了sublime文字2,使用python语言运行代码时遇到问题。 Here is my code: 这是我的代码:

def main:
    print "Hello"
main()

I get an error when I do ctrl + B: 当我按Ctrl + B时​​出现错误:

[Error 2] The system cannot find the file specified [错误2]系统找不到指定的文件

[cmd: [u'python', u'-u', u'C:\\Users\\Hari\\Documents\\test.py']] [cmd:[u'python',u'-u',u'C:\\ Users \\ Hari \\ Documents \\ test.py']

[dir: C:\\Users\\Hari\\Documents] [dir:C:\\ Users \\ Hari \\ Documents]

[path: C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Intel\\OpenCL SDK\\2.0\\bin\\x86;C:\\Program Files (x86)\\Intel\\OpenCL SDK\\2.0\\bin\\x64;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon] [Finished] [路径:C:\\ Program Files(x86)\\ Intel \\ iCLS Client \\; C:\\ Program Files \\ Intel \\ iCLS Client \\; C:\\ windows \\ system32; C:\\ windows; C:\\ windows \\ System32 \\ Wbem ; C:\\ windows \\ System32 \\ WindowsPowerShell \\ v1.0 \\; C:\\ Program Files(x86)\\ Intel \\ OpenCL SDK \\ 2.0 \\ bin \\ x86; C:\\ Program Files(x86)\\ Intel \\ OpenCL SDK \\ 2.0 \\ bin \\ x64; C:\\ Program Files \\ Intel \\ Intel(R)管理引擎组件\\ DAL; C:\\ Program Files \\ Intel \\ Intel(R)管理引擎组件\\ IPT; C:\\ Program Files(x86)\\英特尔\\英特尔管理引擎组件\\ DAL; C:\\ Program Files(x86)\\英特尔\\英特尔管理引擎组件\\ IPT; C:\\ Program Files \\ Intel \\ WiFi \\ bin \\; C:\\ Program Files \\ Common Files \\ Intel \\ WirelessCommon] [完成]

I am using Windows 8 and I tried to change the environment variables by adding C:\\Python27\\; 我正在使用Windows 8,并且尝试通过添加C:\\ Python27 \\来更改环境变量; or C:\\Python26\\; 或C:\\ Python26 \\; or C:\\Python33\\; 或C:\\ Python33 \\; or C:\\Python2\\; 或C:\\ Python2 \\; or C:\\Python2\\; 或C:\\ Python2 \\; to the beginning of the path but it still gives me the same error. 到路径的开头,但仍然会给我同样的错误。 Can someone help me? 有人能帮我吗?

You need to edit %APPDATA%\\Sublime Text 2\\Python\\Python.sublime-build 您需要编辑%APPDATA%\\ Sublime Text 2 \\ Python \\ Python.sublime-build

Modify (change) content to: 将内容修改(更改)为:

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

So, change the "C:\\Python27\\" path part to any path/version of Python that exists in your system. 因此,将“ C:\\ Python27 \\”路径部分更改为系统中存在的Python的任何路径/版本。

The easiest way to make sure that changes to environment variables are applied is to reboot Windows. 确保应用对环境变量所做的更改的最简单方法是重新启动Windows。

And if Sublime Text 2 is started from some Python script using subprocess module, then it starts to behave strangely. 而且,如果Sublime Text 2是使用subprocess模块从某个Python脚本启动的,那么它的行为就会异常。

delete all the paths for python on your system...and try to install python again,I recommend python27. 删除系统上python的所有路径...然后尝试再次安装python,我建议使用python27。 in the environments add c:/python27. 在环境中添加c:/ python27。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM