ImportError: No module named - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: ImportError: No module named (/thread-30928.html) |
ImportError: No module named - coltson - Nov-13-2020 Hello. I am facing the following error messages: when executing python optimizer.py The file "optimizer" it is in the current directory, and there is a folder called "optimizers" where the file "MFO.py" lives. So what I am doing wrong? RE: ImportError: No module named - deanhystad - Nov-13-2020 When you post a question don't assume the reader (me) has any idea what you are talking about. PSO, MFO mean nothing to me (particle swarm optimization?). Should they? Is PSO a module or is it something that is defined in a module? The message says that there is no file name optimizers/PSO.py and no file named optimizers.py that defines something named PSO. What are you expecting? What is in the optimizers folder? RE: ImportError: No module named - coltson - Nov-16-2020 Quote: Is PSO a module or is it something that is defined in a module? It is a file with a function def PSOinside of it Quote:What are you expecting? That the file "optimizer.py" runs because there is a "PSO.py" inside the "optimizers" folder Quote:no file named optimizers.py This file has a import optimizers.PSO as psoinside it, I should have mentioned it. RE: ImportError: No module named - Superjoe - Nov-21-2020 If function PSO in MFO.py, you can try: from .optimizers.MFO import PSO as pso |