简体   繁体   中英

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

[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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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