0

Just to get it out of the way, I'm new at Python and coding in general, but very eager to learn how to do it.

The problem is that I can't run Python scripts through Sublime Text. I'm using Mac OS 10.15.7, and I've downloaded the latest version of Python from the official website and then also with Anaconda.

When I try to run any Python script in Sublime, I get the following message:

/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't find '__main__' module in ''
[Finished in 0.3s with exit code 1]
[shell_cmd: python -u ""]
[dir: /private/var/folders/wh/lt9wn7qn7zl4p8xkj67bhpyh0000gn/T/AppTranslocation/86FABCDF-E2DC-4C15-A564-EFE9529B919B/d/Sublime Text.app/Contents/MacOS]
[path: /Users/alexherranz/opt/anaconda3/bin:/Users/alexherranz/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

I looked at some other similar questions here, and I installed the SublimeREPL package as many recommended, but I'm probably missing something, as I still get this error message. It's quite frustrating, as I'd like to run the scripts within Sublime instead of copying it everytime to the terminal.

Is there a fix for the problem I'm running in to? Any ideas appreciated!

2
  • 1
    It sounds like you've got the Python support in Sublime misconfigured or mis-installed somehow. I don't know anything about the editor, so I can't be of specific help. Someone else will hopefully come along who will know more specifically what to tell you to get you rolling. Best of luck! Commented Nov 13, 2020 at 23:35
  • did you try reinstalling the sublimeREPL Commented Nov 14, 2020 at 23:10

3 Answers 3

1

You've entered code in the editor, but you haven't saved it as a .py file. Save the file, hit B, and it should run just fine.

Sign up to request clarification or add additional context in comments.

Comments

1

Make sure you save the file first, before attempting to run it.

Comments

0

If you "save as" the file somewhere on your computer you should be able to then go into the mac version of the file explorer and then double click your file. If it is a file that opens a window, like tkinter or turtle it will run the code normally. If not it should run the code in the mac version of the command prompt. Make sure it is opening the file with python.

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.