0

I'm trying to run Python in Sublime but I get a syntax error because it's running Python 2.7.

I tried to create a new build with

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

but that isn't working either. I made a new Python file with

import sys
print("Sublime is using: ", sys.version)

and I get

('Sublime is using: ', '2.7.16 (default, Oct 16 2019, 00:35:27) \n[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]')

I ran whereis python3 in the terminal and nothing returned. When I did whereis python I got usr/bin/python. When I did which python 3, I got /usr/bin/python.

I have no idea what to do to fix this.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
J. Doe
  • 269
  • 1
  • 8
  • 1
    Did you mean to have a space in `which python 3`? For me, `which` ignores the `3` and just prints the path to python2. – Erty Seidohl Jan 26 '20 at 05:34
  • yes, you're correct. the path is then ```/Library/Frameworks/Python.framework/Versions/3.8/bin/python3```. however, my issue remains with sublime – J. Doe Jan 26 '20 at 05:38
  • Does `/usr/bin/python3` exist? – Erty Seidohl Jan 26 '20 at 05:39
  • that's the thing. when i type ```whereis python3``` in terminal, nothing shows up and i'm not sure why or how to fix it – J. Doe Jan 26 '20 at 05:40
  • Wait, in comment #2 I thought you said running `where python3` returns a path? Or does it return nothing? – Erty Seidohl Jan 26 '20 at 05:41
  • no that's if i do ```whichis``` not ```whereis``` – J. Doe Jan 26 '20 at 05:45
  • i should definitely be seeing some kind of path like ```/usr/bin/python``` (which i get if i do just ```whereis python``` or something – J. Doe Jan 26 '20 at 05:46
  • Here's someone with a similar problem, I think you may need to add your python directory to your path, and perhaps create /usr/bin/python3 as a symlink to your python3 binary location. – Erty Seidohl Jan 26 '20 at 05:49
  • Oops, forgot the link:https://stackoverflow.com/questions/49704364/make-python3-as-my-default-python-on-mac – Erty Seidohl Jan 26 '20 at 05:49

0 Answers0