运行“ python manage.py shell”时,出现以下消息:
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 "D:\Anaconda3\envs\mysite\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Anaconda3\envs\mysite\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "D:\Anaconda3\envs\mysite\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\Anaconda3\envs\mysite\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "D:\Anaconda3\envs\mysite\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "D:\Anaconda3\envs\mysite\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.apps.PollsConfigdjango'; 'polls.apps' is not a package
我尝试了另一种必须使用./manage.py shell --plain
的解决方案,但这是行不通的。还尝试了一个说明ipython版本不正确的解决方案,但该解决方案也对我没有任何解决作用。
答案 0 :(得分:1)
您的Python代码有错误。由于配置无效,无法启动Django。您的exec*()
之一坏了。追溯中给出了可能出问题的提示。
对于实际错误,您需要自己弄清楚,因为这可能涉及在此处从项目中复制粘贴很多代码,因此不太适合StackOverflow问答格式。