I followed these steps to run Python 3 on Sublime Text 3.
Select the menu Tools > Build > New Build System and I entered the following:
{ "cmd": ["python3", "$file"] , "selector": "source.python" , "file_regex": "file \"(...*?)\", line ([0-9]+)" }
After that, I saved it to the following (Mac-specific) directory: ~/Library/Application Support/Sublime Text 3/Packages/User
but I'm getting this error when I'm trying to run my code on Python 3 in Sublime:
[Errno 2] No such file or directory: 'python3'
We can run Python code inside the Sublime Text with the use of these built-in build systems. 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).
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.
Sublime Text can be used for much more than Python development and there are many useful tutorials that are not targeted at a specific programming language which are still useful. Super charge your Sublime Text 3 to increase your productivity provides many shortcuts and tricks for using the editor.
If you want to change the python version in Sublime Text, first of all you have to install the two Python versions and know where you actually installed them. Ensure that by the cmd line you can call a . py script with python2 and python3. Then, in sublime text, go in Tools --> Build System --> New Build System... .
You need to provide the full path to python3, since Sublime Text does not read your ~/.bash_profile
file. Open up Terminal, type which python3
, and use that full path:
{ "cmd": ["path/to/python3", "$file"], "selector": "source.python", "file_regex": "file \"(...*?)\", line ([0-9]+)" }
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