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**
当我从sample.py
from apps.app1.myscipt-folder import script1
我收到以下错误
from apps.app1.myscipt-folder import script1
ModuleNotFoundError: No module named 'apps.app1'; 'apps' is not a package
但是当我在callscript2.py
内对其进行测试时,它可以正常工作。您认为我在这里做错了什么?
答案 0 :(得分:0)
代替from apps.app1.myscipt-folder import script1
试试这个:
from app1.myscipt-folder import script1