问题
My question is the following, I have sublime 2 and sublime repl plugin installed all working fine, the only thing i need is to change the version of python that is running on the sublimerepl built in console. What I mean is, I have python 2.7.5 (which is pre installed with maveriks) running fine in sublime (via sublimerepl), and I have installed via the installer from python.org, python 3.3.3 , that I need to use, I want to run this version of python on the sublimerepl console but I don't know how.
I know that there are alternatives to sublime but none of those are so beautiful as sublime is.
Can someone help me with this ? I've searched for all over the internet and couldn't find anything helpful.
Btw if I use terminal python 3.3.3 is working fine (Terminal>'python3'), I know this is possible beacause a friend of mine got it working and I have installed mine like he did, but mine is not working.
回答1:
@poke's answer is good, but there are a few details to correct that I figured I'd just put in my own answer as they're too long for comments. First, the .sublime-menu
entry should be named Packages/User/SublimeREPL/config/Python/Main.sublime-menu
(naming the file something else won't integrate it into the menu system, it has to be Main.sublime-menu
AFAIK). Also, for your system, you should probably change the "cmd"
lines to point to /Library/Frameworks/Python.framework/Versions/3.3/bin/python3
, which is where the python.org installation is located. So, for example, where it says
"cmd": ["python", "-i", "-u"],
change that to
"cmd": ["/Library/Frameworks/Python.framework/Versions/3.3/bin/python3", "-i", "-u"],
Good luck!
回答2:
Like it or not, but the interpreter is actually hardcoded into the plugin. For Python, this happens in /config/Python/Main.sublime-menu.
I think you have two ways to work around this:
The first option would be to copy that
Main.sublime-menu
file into your local user configuration folder, if you already have one there, you will need to merge both contents. Replace all thepython
calls bypython3
, and adjust thecaption
properties to mentionPython 3
(e.g.Python 3 - RUN current file
).Now, when you launch the command launcher via Cmd+Shift+P (should be the keyboard shortcut in OSX, right?), then you can type
Python 3
and your new commands using thepython3
executable should pop up.The second option would be to clone the plugin into your plugin directory, and modify the original Python
Main.sublime-menu
file in the same way as in the first option. This will get rid of the Python 2 commands, but also prevent you from getting updates from the original repository published over PackageManager; so you would have to make updates yourself.
回答3:
my workaround was this:
Open the file: /Users/ricardomartinez/Library/Application Support/Sublime Text 3/Packages/SublimeREPL/config/Python/Main.sublime-menu
replace the line that says:
"cmd": ["python", "-i", "-u", "-m", "pdb", "$file_basename"],
with:
"cmd": ["/Library/Frameworks/Python.framework/Versions/3.5/bin/python3", "-i", "-u"],
note that is necessary specify the whole route of the python3 exec because i read in another question that Sublime don't read the ~/.bash_profile
Hope that help!
来源:https://stackoverflow.com/questions/20777307/how-to-run-python-3-in-sublime-2-repl-mac