Welcome to OStack Knowledge Sharing 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...