我对python和linux非常陌生,我试图从教程中创建一个应用程序,当我试图运行我的模型的测试时发生了这种情况。
(venv) kali@kali:~/machinelearning/backend/server$ python manage.py test apps.ml.tests
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/kali/machinelearning/venv/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'apps.endpointsapps'
这是我第一个关于堆叠的问题太
请在apps文件夹中添加空的__init__.py
文件,以便Python将其识别为包。
请查看此链接。链路
你能把你的项目结构贴出来吗?基本上只是想看看这些应用程序在哪里。
您需要在apps文件夹中添加一个空的init.py(共4个下划线(文件,以便Python将其识别为一个包。
查看文档以获取更多信息。