I have been teaching myself python and started out using python 2.7.5 and Sublime Text 2. I recently enrolled in a class and they are using python 3.4. I downloaded and installed python 3.4 onto my mac, but am having trouble figuring out how to make Sublime Text use python 3 instead of 2.7. I used..
import sys
print sys.version
to determine which version of python ST was using. It reports back with 2.7.5.
How do I force ST to use python 3?
If I have not included enough information, please don't hesitate to ask.
Find your Python pathChange the “shell_cmd”: “pythonX. X” to your desired python version. Be sure to change the “variants shell_cmd” to the same. Save the file, re-run your test file and you should now see the correct version being run.
Python Version6. Sublime Text's build of Python 3.3. 6 includes a handful of patches backported from Python 3.4 to fix issues with unicode paths and crashes with the ctypes module on 64bit versions of Windows. Starting in build 4050, plugins may also be run using Python 3.8.
As a standard, it is recommended to use the python3 command or python3. 7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed. You can also use commands like py -3.7 to select a particular version, or py --list to see which versions can be used.
By pressing Ctrl + B , Sublime 3 will run the python code inside the integrated console (provided we have saved the file with . py file extension).
Found this on Google.
Create the file ~/.config/sublime-text-2/Packages/Python/Python3.sublime-build
:
{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
You should then be able to choose the Python3 build system.
If that doesn't work, try this:
{
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"encoding": "utf8",
"path": "/Library/Frameworks/Python.framework/Versions/3.3/bin/"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With