繁体   English   中英

如何在Sublime text 2 python中运行代码

[英]How to run code in Sublime text 2 python

我最近安装了sublime text 2,在我决定获得sublime text 3之前试用它,但我无法正确运行任何代码。 我按下了Ctrl + B,得到了这样的输出。

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

我查看了我的漫游文件夹并找到了崇高文本2,因为另一篇文章提到在python文件夹中编辑文件但漫游\\ Sublime Text 2中没有这样的文件夹我所拥有的是安装包,包,Pristine包和设置。 我错过了一些东西,还是我应该知道的明显的东西?

我更喜欢在sublime构建中指定python的完整路径,而不是将python添加到路径中。 Python.exe可能安装在其中一个(或类似的东西)

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

一旦找到它(假设它在C:\\ Program Files(x86)\\ Python27中),编辑pyl的sublime_build。 这是我使用的构建:

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

}

对我来说,这个文件是在

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

Windows无法找到您的python安装。 当您运行如下命令时:

python <your_file.py>

第一个python告诉你的系统找到你的python二进制文件的位置,并尝试用该名称运行一些命令。 通过查看回显的路径,看起来你的系统路径上实际上没有你的python二进制文件。

如果您不确定如何将python添加到path ,请查看此超级用户问题: https//superuser.com/questions/143119/how-to-add-python-to-the-windows-path

暂无
暂无

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

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