Skip to content

ImportError: lxml.html.clean module is now a separate project lxml_html_clean #329

@Safranil

Description

@Safranil

Describe the bug

After upgrading our installation to Debian 12, we encountered on error on uwsgi start:

Traceback (most recent call last):
  File "/home/pytition/www/pytition/pytition/pytition/wsgi.py", line 52, in <module>
    application = get_wsgi_application()
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pytition/pytition_venv/lib/python3.11/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/home/pytition/pytition_venv/lib/python3.11/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/pytition/pytition_venv/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "/home/pytition/pytition_venv/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pytition/www/pytition/pytition/petition/models.py", line 19, in <module>
    from .helpers import sanitize_html
  File "/home/pytition/www/pytition/pytition/petition/helpers.py", line 3, in <module>
    from lxml.html.clean import Cleaner
  File "/home/pytition/pytition_venv/lib/python3.11/site-packages/lxml/html/clean.py", line 18, in <module>
    raise ImportError(
ImportError: lxml.html.clean module is now a separate project lxml_html_clean.
Install lxml[html_clean] or lxml_html_clean directly.

To Reproduce
I followed the installation guide to reinstall dependencies : https://pytition.readthedocs.io/en/stable/installation.html
And done the following:

  1. Changed directory to Pytition installation root
  2. rm -rf pytition_venv
  3. virtualenv -p python3 pytition_venv
  4. cd www/pytition
  5. source ../../pytition_venv/bin/activate
  6. pip3 install -r requirements.txt

To Resolve
To resolve the issue, I installed the now required dependency:

  1. source ../../pytition_venv/bin/activate
  2. pip3 install lxml_html_clean

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions