How can use another module place of HTMLParser in django

Viewed 2032

I have appearing error of HTMLParser, In terminal showing this :-

from django.utils.html import format_html, format_html_join, escape
File "/usr/local/lib/python3.5/dist-packages/django/utils/html.py", line 16, in
from .html_parser import HTMLParser, HTMLParseError
File "/usr/local/lib/python3.5/dist-packages/django/utils/html_parser.py", line 12, in
HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'

Python 3.5 django 1.7.7 Using pip3

According to communities , they saying HTML parser is removed on the Python 3.5 version , on my this old application..

What should I do :-

  • Replace HTMLParser with another similar then How??? OR

  • Downgrade python version I have tried this but it taking by default lib -> /usr/lib/python3.5 How to change this path

Please help on this.

my requirement file requirements/common.txt is like this

# Core Stuff
# -------------------------------------
django>=1.7.7,<1.8
whitenoise==2.0.6

# Authentication
# -------------------------------------
django-facebook==6.0.3
PyJWT==1.4.0

# Notifications
# -------------------------------------
django-twilio-sms-2==1.0.2
hashids==1.1.0
apns==2.0.1

# Extensions
# -------------------------------------
django-extensions==1.6.1
Werkzeug==0.11.3
pytz==2015.7
django-sampledatahelper==0.3
arrow==0.7.0
requests==2.9.1
django-flat-theme==1.1.3

# Configuration
# -------------------------------------
django-sites==0.9
django-secure==1.0.1
python-dotenv==0.3.0
django-environ==0.4.0

# Models
# -------------------------------------
django-model-utils==2.4
django-uuid-upload-path==1.0.0
django-versatileimagefield==1.3
django-jsonfield==0.9.15

# Images
# -------------------------------------
Pillow==3.1.1

# For the persistance stores
# -------------------------------------
psycopg2==2.6.1

# Celery
# -------------------------------------
celery==3.1.20

# Unicode slugification
# -------------------------------------
unicode-slugify==0.1.3
django-autoslug==1.9.3

# Django Rest Framework
# -------------------------------------
djangorestframework==3.3.2
django_filter<=0.11.0  # Do not upgrade until django 1.8
Markdown>=2.3.1,<2.5   # to fix conflict with mkdocs

And requirements/development.txt

-r common.txt

# Documentation
# -------------------------------------
mkdocs==0.15.2
# pygraphviz==1.3rc2
isort==4.2.2

# Debugging
# -------------------------------------
django-debug-toolbar==1.4
ipython==4.1.1
ipdb==0.8.1

# Testing
# -------------------------------------
mock==1.3.0
factory_boy==2.6.0
flake8==2.5.2
pytest==2.8.7
pytest-django==2.9.1
pytest-flakes==1.0.1
pytest-mock==0.10.1
pytest-pythonpath==0.7
coverage==4.0.3
freezegun==0.3.6
pytest-capturelog==0.7

# Versioning
# -------------------------------------
bumpversion==0.5.3

And requirements/production.txt

# Pro-tip: Try not to put anything here. There should be no dependency in
#   production that isn't in development.
-r common.txt

# WSGI Handler
# -------------------------------------
gunicorn==19.4.5

# Caching
# -------------------------------------
django-redis==4.3.0
hiredis==0.2.0

# S3 storgage
# -------------------------------------
# boto==2.39.0
# django-storages-redux==1.3.2

# Logging
# -------------------------------------
newrelic==2.60.0.46

After The requirements installation when I run $ python3 manage.py makemigrations , error appearing this.

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

References tried:
AttributeError: module 'html.parser' has no attribute 'HTMLParseError' https://code.djangoproject.com/ticket/23763

1 Answers
Related