Sublime Forum

Python scripting on Mac "can't find ' __main__ ' module in"

#1

This is my first day of learning Python (I want to use it in biology/bioinformatics) so I am absolutely brand new to programming.

I am not able to run .py formatted files in my terminal. Here is the screenshot of what I’m doing and what I’m getting.

Your feedbacks are appreciated. Thanks!

Aysuns-MacBook-Pro:codes P$ pwd
/Users/P/Desktop/codes
Aysuns-MacBook-Pro:codes P$ ls
gc.py gc2.py gc3.py gcc.py hello.py hellos.py helloworld.py
Aysuns-MacBook-Pro:codes P$ python3 helloworld.py
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3: can’t find ’ main ’ module in ‘/Users/P/Desktop/codes/helloworld.py’
Aysuns-MacBook-Pro:codes P$ python3 --version
Python 3.9.2

0 Likes

#2

Save the file before running/building it.

0 Likes

#3

I saved all of them in codes file on my desktop.

0 Likes

#4

What does your helloworld.py file look like?

1 Like

#5

You are probably saving the file as a Python syntax file then building it as Python 3. Check Tools > Build System to see what is happening, (note where the checkmark is) then reconcile the Build System with the syntax of the file. Resave the file if necessary with the new syntax.

1 Like

#6

You are right! Thank you! I spent whole day yesterday to figure this out!

0 Likes

#7

Solved it. Thank you!

0 Likes