我在我的Django项目中获得了ModuleNotFoundError,我在类似的文章中做了大量的研究,并做了与项目相关的修改,但是运气不好!无法解决这个错误,所以我发布了这个。 项目结构截图->项目结构 加亮为参考。
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 "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/management/base.py", line 361, in execute
self.check()
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 399, in check
for pattern in self.url_patterns:
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 584, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/lib/python3.7/site-packages/django/urls/resolvers.py", line 577, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/venv/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 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/prithvi/pyhtonprojects/DjangoProjects/doc_app/web_app/web_app/urls.py", line 18, in <module>
from web_app.mob_apis.views import login
ModuleNotFoundError: No module named 'web_app.mob_apis'
问题来源StackOverflow 地址:/questions/59379631/django-nomodulefounderror
试着用
from mob_apis.views import login
而不是
from web_app.mob_apis.views import login
在你的 doc_app / web_app web_app / urls . py文件
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。