Emma
Emma

Reputation: 27743

How to run Python3 on Sublime Text 3 on macOS?

I've created a python3.sublime-build:

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

and $ which python3 returns,

/usr/local/bin/python3

likely installed with brew.

and Command + B returns this error:

[Errno 20] Not a directory
[cmd: ['python3', '-u', '/path/to/dir/filename.py']]
[dir: /path/to/dir]
[path: /usr/local/bin/python]
[Finished]

have looked into some relevant posts, and couldn't solve it.

How do I solve the problem?

Upvotes: 2

Views: 2138

Answers (1)

iz_
iz_

Reputation: 16633

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.

Upvotes: 5

Related Questions