我在 python 3.3 中使用 django 1.9.1。 运行 runserver 时出现以下错误
File "/home/virtualenv/python3.3.5/lib/python3.3/site-packages/django/dispatch/__init__.py", line 9, in <module>
from django.dispatch.dispatcher import Signal, receiver # NOQA
File "/home/virtualenv/python3.3.5/lib/python3.3/site-packages/django/dispatch/dispatcher.py", line 14, in <module>
from weakref import WeakMethod
ImportError: cannot import name WeakMethod
正如我在阅读 Weakref 的 WeakMethod 已在 python 3.4 中引入,而它在 python 3.3 的 weakref 中不存在。
有关如何使用 python 3.3 修复相同错误的任何建议。
最佳答案
Django 1.9.x 不支持 Python 3.3:
https://docs.djangoproject.com/en/1.9/faq/install/#what-python-version-can-i-use-with-django
Typically, we will support a Python version up to and including the first Django LTS release whose security support ends after security support for that version of Python ends. For example, Python 3.3 security support ends September 2017 and Django 1.8 LTS security support ends April 2018. Therefore Django 1.8 is the last version to support Python 3.3.
您可以降级到 Django 1.8 或将您的 Python 解释器升级到 3.4 或更高版本。
关于python - 使用 python 3.3 在 Django 1.9 中导入 WeakMethod 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35284560/