【发布时间】:2020-09-06 07:36:46
【问题描述】:
我从 github 下载了一个代码并尝试通过在 git bash 中运行命令来运行它:python manage.py runserver
但我遇到了这个错误:
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
已按照此答案 How to use collections.abc from both Python 3.8+ and Python 2.7 中的建议对我的 manage.py 文件进行了更改 但仍然面临同样的错误。
import os
import sys
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise 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?"
) from exc
execute_from_command_line(sys.argv)
【问题讨论】:
-
基本 DJango 教程在
py manage.py runserver失败并出现同样的错误。
标签: python collections manage.py django-manage.py