Set Up Python 3 Build System with Sublime Text 3

Set up Python 3 build system with Sublime Text 3

The reason you're getting the error is that you have a Unix-style path to the python executable, when you're running Windows. Change /usr/bin/python3 to C:/Python32/python.exe (make sure you use the forward slashes / and not Windows-style back slashes \). Once you make this change, you should be all set.

Also, you need to change the single quotes ' to double quotes " like so:

{
"cmd": ["c:/Python32/python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

The .sublime-build file needs to be valid JSON, which requires strings be wrapped in double quotes, not single.

Sublime Text 3 Python3 build not working?

You can create a new build system for python3 on Linux if the built-in method is not working.

First, open your terminal and write

$ which python3

it will give you the location of python3

/usr/bin/python3

Then in sublime text go to tools -> Build System -> New Build System and paste below code in that file and change location of the python if it is in a different location:

{
"cmd": ["/usr/bin/python3", "-u", "$file"],
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
"selector": "source.python"
}

Now save it using anyname_you_want.sumblime-build and open a python file then select tools -> Build System -> anyname_you_want and run your python file. It should work.

How to run Python3 on Sublime Text 3 on macOS?

IIRC (I haven't used Sublime in a while), path should be the path to the directory, not the executable. Try this instead:

{
"path": "/usr/local/bin/",
"cmd": ["python3", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}

It seems like Python is already in your system PATH though, so the path key seems unnecessary.



Related Topics



Leave a reply



Submit