如何配置 Sublime text 2 以使用我安装的 python 库

问题描述:

我刚开始使用 Sublime Text 2,我似乎无法让它与我为 Windows 2.7 安装的大多数库一起工作,每次我尝试导入它们并运行它时,它都会给我这个消息C:\Python27\Python.exe:在‘’中找不到‘ma​​in’模块".

I just started using Sublime Text 2 and I can't seem to get it to work with most of the libraries I have installed for Python 2.7 for windows, every time I try to import them and run it, it gives me this message "C:\Python27\Python.exe: can't find 'main' module in ''".

我尝试配置 Python.sublime-build 但我对它所做的一切似乎都不起作用,作为参考,这是它现在所拥有的:

I tried configuring the Python.sublime-build but nothing I do to it seems to work, for reference this is what it has right now:

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

我正在学习编程,到目前为止我只使用过 IDLE,所以我对 Sublime 还很陌生,我很可能遗漏了一些东西,如果你们能提供帮助,我将不胜感激.

I'm learning to program and I've only used IDLE so far so I'm very new to Sublime, I'm most likely missing something, if you guys can help I would really appreciate it.

似乎晚了一年但对于这种问题,我认为您只是通过运行无标题"文件来进行测试(这意味着您没有将其保存在 .py 文件下).你必须保存它然后运行它.

Seems to be a year late but for this kind of problem, I think you just test by running on a "untitled" file (which means you didn't save it under .py file). You have to save it then run it.

重点是 sublime text 会调用 cmd,在命令行中调用 python 并将 python 脚本文件名传递给它.如果你不保存文件,就像调用python.exe在空运行一样.

The point is sublime text will call the cmd, call python in command line and pass the python script file name to it. If you don't save the file, it's like calling python.exe to run on nothing.