如何在Sublime text 2 python中运行代码 [英] How to run code in Sublime text 2 python

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

问题描述

我最近安装了崇高的文本2,在我决定获得崇高的文本3之前尝试一下,但是我无法正确运行它的任何代码。我已经按Ctrl + B,并得到这样的输出。

  [错误2]系统找不到指定的文件
[cmd:[u'python',u'-u',u'c:\\\\\\\\\\\\\\\\\\\\\个人代码\\\\' py']]
[dir:C:\Users\Jeff\Desktop\Personal codes]
[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文件(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)\QuickTime\QTSystem \; C:\程序文件(x86)\ Windows Live \\分享]
[已完成]

我查看了我的漫游文件夹,发现崇高文本2,因为另一篇文章提到编辑在python文件夹中的文件,但没有这样的文件夹存在漫游\Sublime文本2我所有的是安装软件包,包,原始包和设置。我是否错过了一些东西,或者是我应该知道的东西?

解决方案

在sublime构建中指定python的完整路径。 Python.exe可能安装在其中一个(或类似的)中。

  C:/ Python 
C:/程序文件/ Python
C:/ Program Files(x86)/ Python
等...

一旦找到它(让它在C:\ Program Files(x86)\Python27)中编辑python的sublime_build。

  {
cmd:[C:\\Program Files (x86)\\Python27 \\\\\\\\\\\\\\\\\`````````,```````````````,`
selector:source.python

}

对于我来说,这个文件在

  Sublime Text \Data\Packages\Python\Python.sublime-build 


I recently installed sublime text 2 to try it out before I decide to get sublime text 3 but I can't properly run any code from it. I've hit Ctrl + B and I get an output like this.

[Error 2] The system cannot find the file specified
[cmd:  [u'python', u'-u', u'C:\\Users\\Jeff\\Desktop\\Personal codes\\print.py']]
[dir:  C:\Users\Jeff\Desktop\Personal codes]
[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)\QuickTime\QTSystem\;C:\Program Files (x86)\Windows Live\Shared]
[Finished]

I've looked in my roaming folder and found sublime text 2 because another post mentioned editing a file in the python folder there but no such folder exists in Roaming\Sublime Text 2 all I have is Installed Packages, Packages, Pristine Packages and Settings. Am I missing something or is it something obvious that I should know?

解决方案

Instead of adding python to the path, I prefer simply specifying the full path to python in the sublime build. Python.exe is probably installed in one of these (or something similar)

C:/Python
C:/Program Files/Python
C:/Program Files (x86)/Python
etc...

Once you found it (lets say its in C:\Program Files (x86)\Python27) edit the sublime_build for python. Here is the build I use:

{
    "cmd": ["C:\\Program Files (x86)\\Python27\\python.exe","-u","$file"],
    "selector": "source.python"

}

for me, this file is in

Sublime Text\Data\Packages\Python\Python.sublime-build

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

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