Mar-05-2018, 06:28 AM
Pages: 1 2
Mar-05-2018, 06:44 AM
(Mar-05-2018, 06:28 AM)sylas Wrote: [ -> ]I renamed my main.py to __main__.py, as you can see on the above error message.I can't see that on the error message because the error message says that it cannot find
__main__
, not that it finds __main__ and is unhappy with it.Try the following experiment: create a folder
foo
containing a single file __main__.py
with the following codeprint('hello world')Then run
Output:python foo
in a console. It should print hello world. On my box (linux) it works both with python 3 and python 2.Mar-05-2018, 07:23 AM
Directory of E:\Documents\foo 05/03/2018 08:19 <DIR> . 05/03/2018 08:19 <DIR> .. 05/03/2018 08:20 21 __main__.py 1 File(s) 21 bytes 2 Dir(s) 467 952 185 344 bytes free E:\Documents\foo>python __main__.py hello world E:\Documents\foo>
Bravo Gribouillis. Your foo works well.
E:\Documents>python foo hello world E:\Documents>
Mar-05-2018, 09:15 AM
I made a mistake while renaming on Py1 the famous __main__.py. So my new Py1 works very well with "python Py1". Thanks again to Gribouillis.
Pages: 1 2