0

Whenever I build (Cmd+B) on Sublime Text 3 it doesn't execute my code.

I used Shift+Command+B to set the build system to Python. I also tried making my own build system by using the which python3.6 command in terminal, which said /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6

I put in this in my custom build system

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

However I still get the same error. Please help.

This is what I get when I try to build

I know this is a really stupid question, I'm sure I just have to change some settings to solve this, thanks for you time.

1
  • The build system in your question doesn't specify the Python that you said you found; however @varunsangal is correct; you need to save the file before the external Python interpreter can run it. Commented Jan 31, 2018 at 3:49

4 Answers 4

1

Looks like Python can't find anything to build.

A couple of quick things:

  1. You don't seem to have saved your file. Save it with a .py extention.
  2. Is Python on your path? Try to type " python " in a cmd terminal.
Sign up to request clarification or add additional context in comments.

1 Comment

Python is definitely in the path because it's the Python interpreter that's displaying the error. You're correct that the issue is that the file hasn't been saved.
0

For sublime text, it's better to use package: Anaconda.

Here is a blog is written in Chinese, but you can follow the pics: https://hanbaobao2005.wordpress.com/2016/06/07/python%E5%A4%9A%E7%89%88%E6%9C%AC-sublime-text-anaconda%E6%8C%87%E5%8C%97/

Comments

0

Open a new file and write this:

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

Save the file as Python3.sublime-build, then change your Build System to Python3 and try to run your code again. Now, it should run successfully.

Comments

0

In my case, I found that the problem was with this line, "selector": "source.python". Once I changed it to "selector": "source.py", and re-open the python program file, it worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.