[英]ModuleNotFoundError: No module named 'my_app'
I am trying to make a custom manager that will run a function from another file in a sibling directory, but this error keeps popping up.我正在尝试制作一个自定义管理器,该管理器将从同级目录中的另一个文件运行一个函数,但此错误不断弹出。 I have tried:
我试过了:
1) Adding the module to my PYTHONPATH. 1) 将模块添加到我的 PYTHONPATH。
2) Adding init .py files. 2) 添加init .py 文件。
3) Appending the module to sys.path. 3) 将模块附加到 sys.path。
I am using Python3 and Django.我正在使用 Python3 和 Django。
- /app
/应用程序
- --- /managers
--- /经理
- -------/manager.py <---
/*importing code here*/
-------/manager.py <---
/*importing code here*/
- --- /my_app
--- /my_app
- -------/request.py <---
/*code to be imported*/
-------/request.py <---
/*code to be imported*/
None of these have worked.这些都没有奏效。
it should work with它应该与
from .. import my_app
or或者
from ..my_app import request
(Be careful with a name like request
, it could conflict the argument request
used inside the views) (小心使用
request
类的名称,它可能会与视图中使用的参数request
冲突)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.