Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,037 members, 7,956,843 topics. Date: Monday, 23 September 2024 at 08:26 PM |
Nairaland Forum / Science/Technology / Programming / Python Programmers Please Help Out (1542 Views)
Programmers, Please Your Golden Advise Is Needed / Python Programmers Lets Meet Here!!! / Programmers, Please Recommend A Good Laptop For Me. (2) (3) (4)
Python Programmers Please Help Out by chiemeriev9: 1:09am On May 26, 2018 |
Greetings everyone, please I seriously need an assistant now... Am new to Python, am writing a program but am having problem in installing my own modules... if I want to import non in built module it will say that it's not a module for instance if I want to import "main" as a new module,,, it will say: error, no module named main. How do I solve the problem ? please you can drop your number for me to contact or whatsapp you if you can help me out you can contact or whatsapp me on 08106990814 Thanks |
Re: Python Programmers Please Help Out by GreatAchiever1: 12:39pm On May 26, 2018 |
chiemeriev9: Don't grab... Is it that u can't import using inheritance. Or u want to install a module using the pip? (Still a newbie tho) |
Re: Python Programmers Please Help Out by AbsoluteMadMan: 4:02pm On May 26, 2018 |
Let's say you have a folder myprogram and this is your working directory. These are the ways you can import modules in that folder. with a file myfolder/main.py you can import using import main # or from .main import x with a file myfolder/myprogram/__init__.py, and another myfolder/myprogram/main.py where the content of myfolder/myprogram/__init__.py is from .main import MyClass you can do: import myprogram cls = myprogram.MyClass() # or from myprogram import MyClass cls = MyClass() |
Re: Python Programmers Please Help Out by 2nioshine(m): 1:21pm On May 27, 2018 |
chiemeriev9:Yea the error is clear. My guess would be either the module is a third party module(ie not present in the python standard library) in this case you have to install using the Python installation manager pip pip install package_name(do this on your comand line /console) Then on your editor, do Import modulename(the name of the module/file) If the module is a sub of another module, do From xyz import zyx eg from time import sleep Or from xyz import * eg from time import * *' just says give me all under the main If this fails maybe no module exist with that name The second reason might be that it is a module you created, if this is the case, ensure the name of the module does not conflict with a standard python module. State clearly the module you are trying to import and you might get a better response and be sure you are not working on a virtual environment (venv) If that is the case then you have to re install all dependencies even tho they previously exist on your PC/machine |
Re: Python Programmers Please Help Out by chiemeriev9: 8:03am On May 28, 2018 |
GreatAchiever1:The modules is not in python library... I created it my self I want to import it on command prompt but it's saying "no module named.... " |
Re: Python Programmers Please Help Out by chiemeriev9: 8:07am On May 28, 2018 |
2nioshine: Have tried installing it using pip but still not working, maybe I made mistakes somewhere, I will try it again please will like to contact / chat you, this my contact thanks |
Re: Python Programmers Please Help Out by chiemeriev9: 8:09am On May 28, 2018 |
AbsoluteMadMan: if I do it that way, they still say "no module named main" plz will like to chat with you 08140688073 |
Re: Python Programmers Please Help Out by chiemeriev9: 9:01am On May 28, 2018 |
2nioshine: ok but what about this one, what do I do?
|
Re: Python Programmers Please Help Out by 2nioshine(m): 9:02am On May 28, 2018 |
chiemeriev9:If you created the module, that means it should likely have the .py extension. Say the file name is game.py If you wish to import this module, you should you ; Import game or from game import the_function_name and not Import game.py Modified I just noticed you updated a screen shot now. Firstly i don't often use python 2. Try Import Queue (capital Q) ie (use a try and except block... Abeg pardon my codes am not using the right tag) try: import Queue as queue except ImportError: import queue For python 3 do try: import queue except ImportError : import Queue as queue I believe the small 'q' works fine for python 3. For the first question try: from urllib.parse import urlparse except ImportError : from urlparse import urlparse or simply from urlparse import urlparse Since you are on python 2 If still doesn't work let me know, so i research on it. We learn everyday |
(1) (Reply)
POS App Developer Needed. / How To Implement Database Driven Website /
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 31 |