Sublime Forum

While running a python program I am getting error can't find '__main__' module in ''

#1

I have saved a python file with name hello.py
and it contains:
print(“Hello World”)

when I am running it from cmd it’s working fine. When the file is open and on that I am going to tools ->build,I am getting the output.
But when I am using Sublime text to run the file hello.py
(i.e: open a new file-> writh hello.py then tools->build), I am getting below error.

C:\Users\APK\AppData\Local\Programs\Python\Python39\python.exe: can’t find ‘main’ module in ‘’

My tools-> build system is also set to python

0 Likes

#2

That error is indeed an indication that the file you’re trying to execute is Python, but not saved to disk; in particular, the '' at the end is what the external Python interpreter thinks the filename is; it being empty is the problem.

You want to double check that the file that you’re trying to build is the one you expect:

0 Likes