Python can't find '__main__' module in ''

来源:互联网 发布:电脑网络维护培训 编辑:程序博客网 时间:2024/05/18 02:32

        st2已经很完善了,以前没有使用过build。似乎st2的build system已经很完善了,何为build?大概就是它自动帮你调用程序运行所需的组件吧。中文资料比较少,我在试用python的时候,就打算直接在st2 build出来。这样就像极一个IDE了。

        在bulid之前,肯定是要先配置好的。首先是Preferences下面的Brower packages,打开之后就看到有一个Python的文件夹。看看里面有没有一个Python.sublime-build 这样名字的文件,如果没有则新建一个。

        里面的内容应该是这样的

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

           然后检查Python有没有加入环境变量path中

C:\Python27

          最后,就可以在st2中build了,新建一个build system,或者使用默认配置,如果你的机器中有多个Python的版本,那么你就应该新建一个python的build。选择好适合的build之后,ctrl+b就可以build了。

print 'hello,world.' //print在python3以后使用print() hello,world. [Finished in 0.1s]

          *如果你没有保存一个文件就build,有可能出来以下的错误:

C:\Python27\python.exe: can't find '__main__' module in ''

           把它保存在Python能够解析的目录,一般是你设置了在环境变量中的那个目录,以便Python能够运行起来。


0 0
原创粉丝点击