Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
397 views
in Technique[技术] by (71.8m points)

python - AttributeError: module 'html.parser' has no attribute 'HTMLParseError'

  1. This is the hints,how can I resolve it?
  2. I use Python 3.5.1 created a virtual envirement by virtualenv
  3. The source code works well on my friend's computer machine

Error:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "A:Python3.5libsite-packagesdjangocoremanagement\__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "A:Python3.5libsite-packagesdjangocoremanagement\__init__.py", line 354, in execute
    django.setup()
  File "A:Python3.5libsite-packagesdjango\__init__.py", line 18, in setup
    from django.utils.log import configure_logging
  File "A:Python3.5libsite-packagesdjangoutilslog.py", line 13, in <module>
    from django.views.debug import ExceptionReporter, get_exception_reporter_filter
  File "A:Python3.5libsite-packagesdjangoviewsdebug.py", line 10, in <module>
    from django.http import (HttpResponse, HttpResponseServerError,
  File "A:Python3.5libsite-packagesdjangohttp\__init__.py", line 4, in <module>
    from django.http.response import (
  File "A:Python3.5libsite-packagesdjangohttp
esponse.py", line 13, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "A:Python3.5libsite-packagesdjangocoreserializers\__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "A:Python3.5libsite-packagesdjangocoreserializersase.py", line 6, in <module>
    from django.db import models
  File "A:Python3.5libsite-packagesdjangodbmodels\__init__.py", line 6, in <module>
    from django.db.models.query import Q, QuerySet, Prefetch  # NOQA
  File "A:Python3.5libsite-packagesdjangodbmodelsquery.py", line 13, in <module>
    from django.db.models.fields import AutoField, Empty
  File "A:Python3.5libsite-packagesdjangodbmodelsfields\__init__.py", line 18, in <module>
    from django import forms
  File "A:Python3.5libsite-packagesdjangoforms\__init__.py", line 6, in <module>
    from django.forms.fields import *  # NOQA
  File "A:Python3.5libsite-packagesdjangoformsfields.py", line 18, in <module>
    from django.forms.utils import from_current_timezone, to_current_timezone
  File "A:Python3.5libsite-packagesdjangoformsutils.py", line 15, in <module>
    from django.utils.html import format_html, format_html_join, escape
  File "A:Python3.5libsite-packagesdjangoutilshtml.py", line 16, in <module>
    from .html_parser import HTMLParser, HTMLParseError
  File "A:Python3.5libsite-packagesdjangoutilshtml_parser.py", line 12, in <module>
    HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As you can read here this error is raised...

because HTMLParseError is deprecated from Python 3.3 onwards and removed in Python 3.5.

What you can do is downgrade your Python version or upgrade your Django version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...