2

So I have a module called gann which itself has a number of modules, the problem is that if I run gannController.py directly it fails.

I have the following file structure(some files omitted):

----convert
 __init__.py
 convert.py
 ----AI
 __init__.py
 ----gann
 gannController.py
 ----model
 __init__.py 
 modelController.py 
 ----util 

now I want to use the gannController.py in the convert.py file.

from AI.gann import gannController

in convert.py does import gannController, however it crashes on the first line which is

from model import modelController

which does work if I run gannController.py directly. As it gives the error:

ModuleNotFoundError: No module named model

So I guess that it's because a submodule uses a submodule of it's own that I cannot run this. Anybody know how to fix this? It's worth noting that I would prefer not to pollute my convert namespace with all of the stuff in model and that I have omitted a few other modules that have the same situation (inside util)

asked Sep 29, 2020 at 10:35
5
  • I'm of course open to question/suggestions. And thank you for taking the time to read my question. Commented Sep 29, 2020 at 10:35
  • What is the error? Commented Sep 29, 2020 at 10:40
  • @GProst ModuleNotFoundError: No module named model Commented Sep 29, 2020 at 10:45
  • from model import modelController This line is in which file? Commented Sep 29, 2020 at 10:50
  • 1
    @EduardoBarrancos It is in gannController.py according to the question. Commented Sep 29, 2020 at 10:51

1 Answer 1

3

Change your import to be relative:

from .model import modelController
answered Sep 29, 2020 at 10:48
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.