Sublime Forum

Help with Python/OS X

#1

Whats up guys, I’m new here and have stumbled upon a problem trying to get Python to work with Sublime Text 2. I’m new to writing code in general (currently in a intro level class) and really like using ST2 as opposed to the standard Python IDLE. When I go to run a program (Command + B), I get this error:

[Errno 13] Permission denied [cmd: [u'/Applications/Python 3.4', u'-u', u'']] [dir: /Users/Cameron/Documents] [path: /usr/bin:/bin:/usr/sbin:/sbin] [Finished]

I have literally no clue what is wrong since I’m new to this all. I tried to follow this video to set up everything:https://www.youtube.com/watch?v=6ZpuwW-9T54

I changed Python.sublime-build to this:

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

What do I need to do to get a fully functional Python setup? Thanks in advance!

0 Likes

#2

OSX already comes with python installed so just change the executable path to “/usr/bin/python” instead of “/Applications/Python 3.4”. Also, Sublime already has a Python build system too, just select it in the “Tools > Build System” menu.

0 Likes

#3

Thanks for this, I went ahead and changed it and got a little further this time, but came across this error now:

/usr/bin/python: can't find '__main__' module in '' [Finished in 0.0s with exit code 1]

0 Likes

#4

[quote=“thetedderbear”]
Thanks for this, I went ahead and changed it and got a little further this time, but came across this error now:

/usr/bin/python: can't find '__main__' module in '' [Finished in 0.0s with exit code 1][/quote]

Have you saved the file you’re trying to run?

0 Likes

#5

Boy do I feel dumb now. Thanks for the help!

0 Likes

#6

That will only work if you want to use the version that comes by default with OS X which is Python 2.7.
If what you want is 3.4 ( and I assume OP does since he was using the path for “/Applications/Python 3.4”) the code you want to use is :

{
    "cmd": "python3", "-u", "$file"],
    "file_regex": "^ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "encoding": "utf8",
    "path": "/Library/Frameworks/Python.framework/Versions/3.4/bin/"
}

If you run:

import sys
print(sys.version)

That will print the current version of Python you are using.

I know this post is a bit late from the original post, but I hope this helps someone else, like it helped me.

0 Likes