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?
Instead of from apps.app1.myscipt-folder import script1
Try this:
from app1.myscipt-folder import script1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.