Sublime Forum

Can't find '__main__' module in ''

#1

Hi I’m very new to programming and I want to try Python 3 with Sublime 3. But I can’t get it to work at all. When I try to build it says this:

C:\Windows\system32\python.exe: can't find '__main__' module in '' [Finished in 0.2s with exit code 1] [shell_cmd: python -u ""] [dir: C:\Program Files\Sublime Text 3] [path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static]

I installed Python 3.3 and Sublime 3 Build 3059

The code I try to build is just a simple print "Hello, world!"

I also tried it on my laptop but with the same results. I’ve tried googling it but I can’t find anything that’s simple enough for me to understand, a lot of it seems to be on Linux as well. The only thing I found out was that copying the Python.exe to system32 should work, I’ve done that and it doesn’t work. I’ve also seen something about changing a path, no clue what that is either.

Someone please help me? :cry:

1 Like

#2

In python > 3.0

print is a regular function so its used like this:
print(‘hello world’)

not like this
print ‘hello world’

So if you are starting, better use a tutorial for python 3 and not one for python 2.x

0 Likes

#3

[quote=“monobotsoft”]In python > 3.0

print is a regular function so its used like this:
print(‘hello world’)

not like this
print ‘hello world’

So if you are starting, better use a tutorial for python 3 and not one for python 2.x[/quote]

Okay I tried to do that instead and it gave me the same result. Still can’t find ‘main’ module in ‘’ :confused:

0 Likes

#4

Lighthammer,
Welcome! First of all, you need to SAVE your code file with the “.py” extension. Then, on the ‘Tools/Build System’ menu, make sure your build system is set to either ‘auto’ or ‘Python’. What that message is telling you is there is no valid Python file to ‘build’ (or, in this case just run).

That should do it. But now, seriously, as monobotsoft said, do yourself a big favor and do a good bit of the tutorial in the Python doc first.
Job 1 is: Learn some Python. THEN you mess with advanced tools that only complicate things and distract you from the main mission.
I would seriously suggest just using the “Idle” app that should have come with your Python install. It’s designed for learning. Get your basics down first, then come to ST, cuz you’re gonna need 'em. :smiley:

Dave

2 Likes

#5

[quote=“oldwarhorse”]Lighthammer,
Welcome! First of all, you need to SAVE your code file with the “.py” extension. Then, on the ‘Tools/Build System’ menu, make sure your build system is set to either ‘auto’ or ‘Python’. What that message is telling you is there is no valid Python file to ‘build’ (or, in this case just run).

That should do it. But now, seriously, as monobotsoft said, do yourself a big favor and do a good bit of the tutorial in the Python doc first.
Job 1 is: Learn some Python. THEN you mess with advanced tools that only complicate things and distract you from the main mission.
I would seriously suggest just using the “Idle” app that should have come with your Python install. It’s designed for learning. Get your basics down first, then come to ST, cuz you’re gonna need 'em. :smiley:

Dave[/quote]

I did follow a tutorial, but apparently it must have been for Python 2 then. I think I got it to work, a CMD window flashes real quick with something I think is “Hello, world!”.

This tutorial you’re talking of, where can I find it? I launched the IDLE (Python GUI) program, I’m guessing that’s what you mean by using the “idle” app.
Any help is much appreciated!

1 Like

#6

I think your problem is that python is not in your path … to test it simply type " python " (without the quotes) in a cmd terminal … if the interpreter shows means that its correctly in your path … else you have to add it to you windows paths, how? --> stackoverflow.com/questions/6318 … -windows-7

just change the python27 for your python3 path and voila!

0 Likes

#7

i have a solution please mail me :slight_smile:

0 Likes

#8

upiyush11@gmail.com

0 Likes

#9

just before you execute the program first save that file

1 Like

#10

Please make sure that you’ve saved the file with ‘.py’ extension.

1 Like

#11

mannnn this work for me. Ty this is simple but make me confuse for quite a while. Once again thx

0 Likes