How To: Run Python 2.7 and Python 3.5 Script in Sublime Text 3

Python

Video is ready, Click Here to View ×


A quick tutorial on how to run either a Python 2.7 script or a Python 3.5 script using Sublime Text 3.

The contents of the sublime-build file are:

{
“cmd”: [“/usr/bin/python3”, “$file”],
“selector”: “source.python”,
“file_regex”: “file “(…*?)”, line([0-9]+)”
}

If you are using either Mac or Windows, instead of using the “whereis” command to find your installation path to Python, you can just run the following script, which will output the path to where Python is installed on your…

12 thoughts on “How To: Run Python 2.7 and Python 3.5 Script in Sublime Text 3

  1. I am facing input output problem… i can not get output if i use import sys and want to print any variable using this value
    code:
    import sys
    n = int(input("enter a number : "))

    print("the number is : " + n)

    output:
    enter a number :

    but when i enter a number , I dont get the printed line "the number is <any number>"

  2. I'm having the same problem as some of the other people. "whereis" won't return anything. I'm using a MacBook Pro.

    I tried running the script below on Sublime, but I'm not getting anything either. Help!

    import os
    import sys
    os.path.dirname(sys.executable)

  3. Hello, I believe I've correctly followed all the steps in this video, but when I run my Python 3 script using the Python3 build, I get this message down in the console:

    [Errno 13] Permission denied
    [cmd: ['/Library/Frameworks/Python.framework/Versions/3.6/bin', '/Users/hp2/Desktop/pythonstuff/test.py']]
    [dir: /Users/hp2/Desktop/pythonstuff]
    [path: /Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands]
    [Finished]

    I am using macOS 10.13.2 (High Sierra) and Sublime Text 3. I used the directory '/Library/Frameworks/Python.framework/Versions/3.6/bin' for the Python3 build, which is the directory I got when I ran the os.path.dirname(sys.executable) line. Any insights?

    I believe the problem has something to do with the permissions in one or more of my directories, but I have no idea what the specific problem is or how to fix it.

    EDIT: Now this appears to be a pointless comment, as I have found the solution here:
    https://stackoverflow.com/questions/39187323/im-getting-errno-13-permission-denied-when-trying-to-use-python
    I simply changed the directory for the Python3 build to '/usr/local/bin/python3.6'
    I will leave this comment up in case anybody else comes across the same problem.

  4. thanks for copying the message in the comments because I do not get that message and would would have had to write it my self, because mine says:
    'python' is not recognized as an internal or external command,
    operable program or batch file.
    [Finished in 0.1s]

Leave a Reply

Your email address will not be published. Required fields are marked *