简体   繁体   English

Sublime Text 2无法构建和运行系统Python

[英]Sublime text 2 not able to build and run system Python

This is my first time trying to link python and sublime text 2, my code is correct and runs easily through the python console but when I try to run it through sublime text I recieve an Error 这是我第一次尝试链接python和sublime文本2,我的代码是正确的,并且可以轻松地通过python控制台运行,但是当我尝试通过sublime文本运行它时,我收到错误消息

[Error 2] The system cannot find the file specified
[cmd:  [u'python', u'-u', u'C:\\Users\\Ben\\Desktop\\Api project\\api.py']]
[dir:  C:\Users\Ben\Desktop\Api project]
[path: C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA      Corporation\PhysX\Common;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 (x86)\GNU\GnuPG\pub;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\]
[Finished]

I believe I have not set up python correctly but any suggestions would be hugely appreciated. 我相信我没有正确设置python,但是任何建议将不胜感激。 Also code is as follows 另外代码如下

import urllib2
import json

locu_api = 'myapikey'

url = 'https://api.locu.com/v1_0/venue/search/?locality=New%20York&category=restaurant&api_key=myapikey'
json_obj = urllib2.urlopen(url) #Json data (displays the pulled url data)

data = json.load(json_obj)

print data

After hashing it out, it appeared I hadn't added the python directory to my system path's environement, with that being resolved it all now works as hoped. 将其散列后,似乎我还没有在系统路径的环境中添加python目录,现在解决了所有问题,现在可以按预期运行。 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. 选择它,然后按编辑。 Adding in the desired path C:\\Python27 添加所需的路径C:\\ Python27

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

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