-1

This question is similar to the following questions:

  1. python import class in init.py from file in same package
  2. how to import classes defined in init.py

However, the solutions there did not work for me.

At runtime I always get the following error:

 ImportError: no module named 'project'

My project directory is simple

project\
   - project\
   -   __init__.py
   -   views.py
   -   modules.py

When I try to import from the init.py file

I use

from . import app 

or

from project import app

I am getting the error I stated above.

I can't seem to figure it out. please help!!!

Rann Lifshitz
  • 4,040
  • 4
  • 22
  • 42

1 Answers1

0

After davidism advice, this is what i did, just incase someone else have this issue.

I created a file called manage.py in the top directory, just as shown below.

project\
   - **manage.py**
   - project\
       -   __init__.py
       -   views.py
       -   modules.py

In manage.py i imported my app instance defined in my config.py and run

 # manage.py file
 --------------------------------

 from project.config import app

 if __name__ == "__main__":
    app.run()

Then you finish off by running the manage.py file

projectslocation\project>python3 manage.py

Everything works!!!