Problems with running Python 32 in Sublime Text 2

2019-08-30 11:21发布

问题:

I know that there are lots of questions about running Python in Sublime Text 2, but i have a problem.

I've changed "Python.sublime-build" file in AppData package on this one

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

Where "C:\Program Files\Python32\python.exe" is my own path. When I press Ctrl + B. I see "building..." and than the inscription disapeers and nothing happens.

What to do. help me please!

回答1:

You shouldn't be modifying any files in AppData/Roaming/Sublime Text 2/Packages/ unless they're in the User/ directory. Any changes will be overwritten upon upgrade, and if you break something (unless you've made backups) you might not be able to fix it without reinstalling.

So, change Packages/Python/Python.sublime-build back to the following:

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

Next, create a new file Packages/User/Python3.sublime-build with the following contents:

{
    "cmd": ["c:/Program Files/Python32/python.exe", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

Save the file, then go to the Tools -> Build System menu and select Python3. You should now be able to run a Python 3 file by hitting CtrlB. I'd suggest running the one below, as it will show if your Python installation is working properly:

import sys
print(sys.version)