Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.4 on Sublime Text 3

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' 
like image 699
user3555502 Avatar asked Apr 24 '14 01:04

user3555502


People also ask

How do I run Python in Sublime Text 3?

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

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.

Is Sublime Text good for Python?

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.

How do I replace Python in Sublime Text?

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


1 Answers

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]+)" } 
like image 176
Andrew Avatar answered Sep 20 '22 19:09

Andrew