How Do I Run Python 3.5 In Sublime Text 3
Solution 1:
Yes, you can use any Python version you want to run programs from Sublime - you just need to define a new build system. Select Tools -> Build System -> New Build System
, then delete its contents and replace it with:
{
"cmd": ["C:/Python35/python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
assuming that C:/Python35/python.exe
is the correct path. If python.exe
resides someplace else, just put in the correct path, using forward slashes /
instead of the Windows standard backward slashes \
.
Save the file as Packages/User/Python3.sublime-build
, where Packages
is the folder opened by selecting Preferences -> Browse Packages...
- Sublime should already automatically save it in the right directory. Now, there will be a Tools -> Build System -> Python3
option that you can select for running files with Python 3.
For details on setting up SublimeREPL with Python 3, please follow the instructions in my answer here.
Solution 2:
if you have installed python3 and SublimeREPL, you can try setting up key bindings with the correct path to the python3 file.
[
{
"keys":["super+ctrl+r"],
"command": "repl_open",
"caption": "Python 3.6 - Open File",
"id": "repl_python",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": ["The directory to your python3.6 file", "-i", "$file"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {"PYTHONIOENCODING": "utf-8"}
}
}
]
You can try by copying this code into your /Sublime Text 3/Preferences/Key Bindings/
Hope this helps!
Post a Comment for "How Do I Run Python 3.5 In Sublime Text 3"