0
Django project folder structure

    project (source root)
    -->apps
    ---->**app1**
    ----->admin.py
    ----->init.py
    ----->apps.py
    ----->models.py
    ----->urls.py
    ----->views.py
    ----->callscript2.py
    ----->**myscipt-folder**
    ------>script1.py
    ------>script2.py
    ------>__init__.py
    ---->**app2**
    ----->admin.py
    ----->init.py
    ----->apps.py
    ----->models.py
    ----->urls.py
    ----->views.py
    ----->sample.py (must be able to call the script2 from app1, myscript folder)
    ---->**app3**

When I call the file from sample.py

from apps.app1.myscipt-folder import script1

I get the following error

from apps.app1.myscipt-folder import script1
ModuleNotFoundError: No module named 'apps.app1'; 'apps' is not a package

But when I test it inside the callscript2.py it works fine. What do you think I do wrong here?

Taku
  • 31,927
  • 11
  • 74
  • 85
  • 1
    Possible duplicate of [Importing files from different folder](https://stackoverflow.com/questions/4383571/importing-files-from-different-folder) – Agile_Eagle Jul 07 '18 at 16:45
  • Possible duplicate of [Python - Module Not Found](https://stackoverflow.com/questions/37233140/python-module-not-found) – iamjoebloggs Jul 07 '18 at 17:25

1 Answers1

0

Instead of from apps.app1.myscipt-folder import script1
Try this:

from app1.myscipt-folder import script1
Wariored
  • 1,303
  • 14
  • 25