Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set which version of python sublime text uses

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.

like image 795
Wyze Avatar asked Apr 18 '14 20:04

Wyze


People also ask

How do I change the version of Sublime in Python?

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.

What version of Python does sublime use?

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.

How do I change which version of Python is installed?

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.

How do I run python3 on Sublime Text?

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).


1 Answers

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/"
}
like image 115
kitti Avatar answered Sep 23 '22 09:09

kitti