AttributeError:模块“html.parser”没有属性“HTMLParseError”

新手上路,请多包涵
  1. 这是提示,我该如何解决?
  2. 我使用 Python 3.5.1 通过 virtualenv 创建了一个虚拟环境
  3. 源代码在我朋友的电脑上运行良好

错误:

 Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "A:\Python3.5\lib\site-packages\django\core\management__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "A:\Python3.5\lib\site-packages\django\core\management__init__.py", line 354, in execute
    django.setup()
  File "A:\Python3.5\lib\site-packages\django__init__.py", line 18, in setup
    from django.utils.log import configure_logging
  File "A:\Python3.5\lib\site-packages\django\utils\log.py", line 13, in <module>
    from django.views.debug import ExceptionReporter, get_exception_reporter_filter
  File "A:\Python3.5\lib\site-packages\django\views\debug.py", line 10, in <module>
    from django.http import (HttpResponse, HttpResponseServerError,
  File "A:\Python3.5\lib\site-packages\django\http__init__.py", line 4, in <module>
    from django.http.response import (
  File "A:\Python3.5\lib\site-packages\django\http\response.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "A:\Python3.5\lib\site-packages\django\core\serializers__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "A:\Python3.5\lib\site-packages\django\core\serializers\base.py", line 6, in <module>
    from django.db import models
  File "A:\Python3.5\lib\site-packages\django\db\models__init__.py", line 6, in <module>
    from django.db.models.query import Q, QuerySet, Prefetch  # NOQA
  File "A:\Python3.5\lib\site-packages\django\db\models\query.py", line 13, in <module>
    from django.db.models.fields import AutoField, Empty
  File "A:\Python3.5\lib\site-packages\django\db\models\fields__init__.py", line 18, in <module>
    from django import forms
  File "A:\Python3.5\lib\site-packages\django\forms__init__.py", line 6, in <module>
    from django.forms.fields import *  # NOQA
  File "A:\Python3.5\lib\site-packages\django\forms\fields.py", line 18, in <module>
    from django.forms.utils import from_current_timezone, to_current_timezone
  File "A:\Python3.5\lib\site-packages\django\forms\utils.py", line 15, in <module>
    from django.utils.html import format_html, format_html_join, escape
  File "A:\Python3.5\lib\site-packages\django\utils\html.py", line 16, in <module>
    from .html_parser import HTMLParser, HTMLParseError
  File "A:\Python3.5\lib\site-packages\django\utils\html_parser.py", line 12, in <module>
    HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'

原文由 HyperZhang 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 731
1 个回答

正如您 在此处 阅读到的那样,出现了此错误…

因为 HTMLParseError 从 Python 3.3 开始弃用并在 Python 3.5 中删除。

您可以做的是降级您的 Python 版本或升级您的 Django 版本。

原文由 mazulo 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题