问题
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 ''".
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"
}
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/16945908/how-to-configure-sublime-text-2-to-use-my-installed-python-libraries