Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

python - sublime build system error "can't find '__main__' module in ''"

I'm trying to get Sublime3 to work with Python3.6.5 and getting an error message below.

/usr/bin/python: can't find '__main__' module in ''
[Finished in 0.1s with exit code 1]
[shell_cmd: python -u ""]
[dir: /Applications/Sublime Text.app/Contents/MacOS]
[path:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This error is indicative of your not having saved your Python script file before you tried to run the build. In particular notice that in your posted output, you see the shell_cmd that was executed as:

[shell_cmd: python -u ""]

That is, it's trying to execute python with an empty file name. For example, compare that to the contents of your sublime-build file, which probably looks something like:

"shell_cmd": "python -u "$file"",

If the file is not saved, the file has no name, and as a result, the Python interpreter complains about the same thing:

/usr/bin/python: can't find '__main__' module in ''

The module name is an empty string (''), which should be the name of the file that you're trying to execute.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...