gpt4 book ai didi

python - django 项目中的 py 测试 ImportError : No module named simple while running manage.

转载 作者:行者123 更新时间:2023-11-28 22:42:06 26 4
gpt4 key购买 nike

回溯:

./manage.py test my_app
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 381, in run_from_argv
parser = self.create_parser(argv[0], argv[1])
File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 354, in create_parser
self.add_arguments(parser)
File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 52, in add_arguments
test_runner_class = get_runner(settings, self.test_runner)
File "/home/zuber/projects/private-CR/env/local/lib/python2.7/site-packages/django/test/utils.py", line 152, in get_runner
test_module = __import__(test_module_name, {}, {}, force_str(test_path[-1]))
ImportError: No module named simple

我试图从应用程序文件夹中删除 init.py,然后我得到“没有名为 app_name 的模块”。当我从项目文件夹中删除 init.py - 控制台显示“没有名为设置的模块”。如何测试我的应用?

最佳答案

所以首先,你需要把你的两个 __init__.py回到你找到它们的地方。它们允许您从该模块导入内容。其次,您应该在 manage.py 中发布代码所以我们对发生的事情有了更好的了解,但在我看来你有一条线看起来像 import django.contrib.admin.utilimport <something> from django.contrib.admin.util .此模块已在您使用的 django 版本中删除,因此您应该替换所有出现的 django.contrib.admin.util。与 django.contrib.admin.utils .

关于python - django 项目中的 py 测试 ImportError : No module named simple while running manage.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32011809/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com