0

let's say in my working project directory I have this tree structure :

- project
    - lib
        - monitoring
            - analysis.py
            - database.py
            - monitor.py
            - files.py
        - server.py
        - exec.py
    - template
        - some HTML files

file: analysis.py

from files import *;
from database import db;

file: files.py

#this script doesn't import from any of them

file: monitor.py

from database import db;
from files import Time, isFileExists

file: database.py

from files import *;

file: server.py

from exec import Run;
from monitoring.files import rootFolder , subContent , ROOTPATH , FOLDERNAME , Time , fullDate;

file: exec.py

from monitoring.analysis import Collect;

My problem occures when I run script exec.py I got : ModuleNotFoundError: No module named 'database'

udit kanotra
  • 328
  • 1
  • 3
  • 17
Kirollos Nasr
  • 315
  • 1
  • 7
  • please refer to this question https://stackoverflow.com/q/4383571/11548820 – udit kanotra Jun 12 '19 at 08:31
  • @uditkanotra Thanks for your reply. I read this question before. But I think my question is a little bit different. In my question *exec.py* is in the same level of *monitoring* folder – Kirollos Nasr Jun 12 '19 at 12:56

1 Answers1

0

Try this:

ADD __init__.py file in the monitoring folder, this is to inform python that monitoring is also a python package from which we can import modules

Ensure that a file called __init__ is added to the folder that contains the module you want to import. This file is typically empty.

Chetan Vashisth
  • 438
  • 4
  • 14