thefourtheye's weblog

opinions are my own; try code/suggestions at your own risk

Python 3.5 and Django 1.7's HTMLParseError

| Comments

I just updated my Python installation to 3.5 Alpha 1 and started with Django today and I hit a road block already. It all went fine, when I created the virtual environment and installed Django 1.7.4 in it. And then when I did startproject, I got AttributeError: module 'html.parser' has no attribute 'HTMLParseError'.
(py3.5venv) ➜  myProject git:(master) ✗ startproject myProject
Traceback (most recent call last):
File "/py3.5venv/bin/", line 5, in
File "/py3.5venv/lib/python3.5/site-packages/django/core/management/", line 385, in execute_from_command_line
File "/py3.5venv/lib/python3.5/site-packages/django/core/management/", line 354, in execute
File "/py3.5venv/lib/python3.5/site-packages/django/", line 18, in setup
from django.utils.log import configure_logging
File "/py3.5venv/lib/python3.5/site-packages/django/utils/", line 13, in
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/py3.5venv/lib/python3.5/site-packages/django/views/", line 10, in
from django.http import (HttpResponse, HttpResponseServerError,
File "/py3.5venv/lib/python3.5/site-packages/django/http/", line 4, in
from django.http.response import (
File "/py3.5venv/lib/python3.5/site-packages/django/http/", line 13, in
from django.core.serializers.json import DjangoJSONEncoder
File "/py3.5venv/lib/python3.5/site-packages/django/core/serializers/", line 23, in
from django.core.serializers.base import SerializerDoesNotExist
File "/py3.5venv/lib/python3.5/site-packages/django/core/serializers/", line 6, in
from django.db import models
File "/py3.5venv/lib/python3.5/site-packages/django/db/models/", line 6, in
from django.db.models.query import Q, QuerySet, Prefetch # NOQA
File "/py3.5venv/lib/python3.5/site-packages/django/db/models/", line 13, in
from django.db.models.fields import AutoField, Empty
File "/py3.5venv/lib/python3.5/site-packages/django/db/models/fields/", line 18, in
from django import forms
File "/py3.5venv/lib/python3.5/site-packages/django/forms/", line 6, in
from django.forms.fields import * # NOQA
File "/py3.5venv/lib/python3.5/site-packages/django/forms/", line 18, in
from django.forms.utils import from_current_timezone, to_current_timezone
File "/py3.5venv/lib/python3.5/site-packages/django/forms/", line 15, in
from django.utils.html import format_html, format_html_join, escape
File "/py3.5venv/lib/python3.5/site-packages/django/utils/", line 16, in
from .html_parser import HTMLParser, HTMLParseError
File "/py3.5venv/lib/python3.5/site-packages/django/utils/", line 12, in
HTMLParseError = _html_parser.HTMLParseError
AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
Then Antti Haapala (a friend from Stakoverflow's Python Chat room) found out that it is because HTMLParseError is deprecated from Python 3.3 onwards and removed in Python 3.5, as per the official documentation. He continued the investigation and found out that django guys are already aware of this, as they have a bug raised, and the fix has been already delivered to the code repository.
Now, all we can do is, wait for the version of django which officially supports Python 3.5 or manually patch file as per the above shown fix. Even if we patch it manually, there is no guarantee that everything else will work fine.