我尝试通过 python manage.py <folder_name>
启动一个 Django 项目只是为了获得以下堆栈跟踪:
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\pythonProject\web_projects\mysite\manage.py", line 12, in main
from django.core.management import execute_from_command_line
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\django\core\management\__init__.py", line 12, in <module>
from django.conf import settings
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\django\conf\__init__.py", line 19, in <module>
from django.utils.deprecation import RemovedInDjango40Warning
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\django\utils\deprecation.py", line 5, in <module>
from asgiref.sync import sync_to_async
ModuleNotFoundError: No module named 'asgiref'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\pythonProject\web_projects\mysite\manage.py", line 23, in <module>
main()
File "C:\Users\User\PycharmProjects\pythonProject\web_projects\mysite\manage.py", line 14, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you
forget to activate a virtual environment?
最后一行清楚地表明缺少什么,但 Django 已经安装。第一次,它没有包含在 venv
文件夹中,但即使在通过原始复制粘贴机制包含它之后它也没有执行。怎么解决?