• Register
1 vote
326 views

Problem:

Hello,

Python learning is being hard for me. I just about to start running my very first python program. I’ve installed a fresh python set-up on my machine and done writing my first program.

print  "Hello Python!"

However, the program is not running in my case and producing an error:

can't find '__main__' module in ''

Why does the problem occur? How can I get out of this? I am looking forward to having a legit solution for it.

Thanks,

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution:

Well, the error message indicates that you don’t have a valid python file to build in this particular program. So, make sure you saved your program with a .py extension. After then, on the ‘Tools/Build System’ menu, make sure your build system is set to either ‘auto’ or ‘Python

I think you should read the python documentation very clearly before giving it a clinical start. You, do have to have strong knowledge of a certain programming language before starting it. Go here and read the documentation first.

In the latest python version, you have to use parenthesis in a print function. You want to do something like this

print ("Hello World!");

Good Day!

13 9 6
94,240 points

Related questions

0 votes
1 answer 8 views
8 views
Problem: Tried running a file with the following imports: from flask_sqlalchemy import sqlalchemy from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker Received the following error: ImportError: No module named 'flask_sqlalchemy' SQLAlchemy is installed. Still, I tried to reinstall into the directory in which it will be used.
asked 2 days ago Mashhoodch 9.1k points
0 votes
1 answer 21 views
21 views
Problem: have troubles to import the basemap module of mpl_toolkits in python. Here is what I get when I run the test.py script from the module directory: /usr/lib/python2.7/dist-packages/mpl_toolkits/basemap$ python test.py Traceback (most recent call last): File "test. ... " directory. There is no problem to import mpl_toolkits. Here is a thing I tried, to manually add the path, and the result:
asked Feb 14 Mashhoodch 9.1k points
0 votes
1 answer 35 views
35 views
Problem: I am using Ubuntu and have installed Python 2.7.5 and 3.4.0. In Python 2.7.5 I am able to successfully assign a variable x = Value('i', 2), but not in 3.4.0. I am getting: Traceback (most recent call last): File "<stdin>", line 1, ... File "/usr/local/lib/python3.4/ctypes/__init__.py", line 7, in <module> from _ctypes import Union, Structure, Array ImportError: No module named '_ctypes'
asked Jan 26 Mashhoodch 9.1k points
0 votes
1 answer 11 views
11 views
I'm installing python on my windows 10 laptop, and when I try to run it I get this. Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' Current thread 0x0000037c (most recent call first):
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 543 views
543 views
I would like to get a list of names of built-in modules in python such that I can test the popularity of function's naming conventions (underline, CamelCase or mixedCase). I know there is a Global Module Index but I am wondering if there is a list of strings, which is ... :) Update: len(dir(__builtins__)) = 145 len(stdlib_list("2.7")) = 430 help('modules') = 508 # counting manually the output
asked Oct 25, 2020 psandprop 2.4k points
0 votes
1 answer 24 views
24 views
I wanna use scikit-learn. I have typed pip install -U scikit-learn pip3 install sklearn to install it; but when i type $ Python >>> import sklearn it returns ImportError: No module named sklearn I followed other tutorials, but it doesn't work. Furthermore, my enviroment ... . What is the true code to type in the terminal? I tried to type python setup.py installin the terminal but it doesn't work
asked Oct 24, 2020 psandprop 2.4k points
1 vote
2 answers 65 views
65 views
Problem: I am new in python programming. I trired to istall pygame and I wrote some code about it: import sys import settings import pygame def run_game(): pygame.init() all_settings = settings() screen = pygame.display.set_mode( (all_settings.screen_width, all_settings ... config". Please make sure a development version of SD L is installed. ImportError: No module named 'pygame' Can anybody help?
asked Mar 27, 2020 LizzyM 6.1k points
1 vote
1 answer 264 views
264 views
Problem : I am beginner to Python. Currently if I try to use the request module to have the urls text then I often face below Error: Traceback (most recent call last):  File "/usr/local/lib/python3.6/site-packages/requests-2.18.1-py3.5.egg/requests/adapters.py" ... to get the url's text to parse it. Please find below my line of code for your reference: mytext = requests.get(detail_path).mytext
asked May 2, 2020 stewart 4k points
0 votes
1 answer 14 views
14 views
Problem: Before executing code, Python interpreter reads source file and define few special variables/global variables. How to python interpreter is running that module (the source file) as the main program, it sets the special __name__ variable to have a value &ldquo ... module, __name__ will be set to the module&rsquo;s name. Module&rsquo;s name is available as value to __name__ global variable?
asked Jan 11 Mashhoodch 9.1k points
0 votes
2 answers 483 views
483 views
Problem: Hello guys, I am running this code in visual code but dont know why the error ic coming can you please check the error of if__name__ ==__main__invalid syntax. def main(): generateRandomNumbers() def generateRandomNumbers(): print ('Test') si_ze = 0 nameLength=0 ... == "__main__" main() Getting Syntax error if name == main ^ SyntaxError: invalid syntax Process finished with exit code 1
asked Jun 9, 2020 Gavin 15.3k points