pythonpython-3.xsublimetext3

Sublime Text 3 Python3 build not working?


I have just installed the latest version of Sublime Text 3 on my Linux Pop_!OS Computer but I cannot run a python file.

When I try to build the file with python with CTRL-B it gives me an error in the logs...

bash: python: command not found
[Finished in 0.0s with exit code 127]
[shell_cmd: python -u "/media/kevinapetrei/KEVIN USB/Files/Programming/Python Programs/Finished/HiLo Versions/HiLo-2.02/setup.py"]
[dir: /media/kevinapetrei/KEVIN USB/Files/Programming/Python Programs/Finished/HiLo Versions/HiLo-2.02]
[path: /app/utils/bin:/app/sublime_merge/bin:/app/bin:/usr/bin]

This is pretty weird because I installed a package on terminal which allows me to use command python to run python3. (In terminal I can still run files using command python.

What is wrong? Can I edit this to make it work somehow?


Solution

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