Ckan: "ImportError: No module named [html5lib.]sanitizer"

Created on 27 Sep 2016  路  3Comments  路  Source: ckan/ckan

CKAN Version if known (or site URL)

2.5.2

Please describe the expected behaviour

Upgrade from 2.4.3 (source install)

Please describe the actual behaviour

Traceback (most recent call last):
  File "/usr/lib/ckan/default/bin/paster", line 11, in <module>
    sys.exit(run())
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 102, in run
    invoke(command, command_name, options, args[1:])
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 141, in invoke
    exit_code = runner.run(args)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/script/command.py", line 236, in run
    result = self.command()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 205, in command
    self._load_config(cmd!='upgrade')
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 142, in _load_config
    conf = self._get_config()
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 139, in _get_config
    return appconfig('config:' + self.filename)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 261, in appconfig
    global_conf=global_conf)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
    global_conf=global_conf)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
    return loader.get_context(object_type, name, global_conf)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 454, in get_context
    section)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 476, in _context_from_use
    object_type, name=use, global_conf=global_conf)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 406, in get_context
    global_conf=global_conf)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
    global_conf=global_conf)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
    return loader.get_context(object_type, name, global_conf)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 620, in get_context
    object_type, name=name)
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
    possible.append((entry.load(), protocol, entry.name))
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2258, in load
    return self.resolve()
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2264, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware.py", line 28, in <module>
    from ckan.config.environment import load_environment
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 18, in <module>
    import ckan.lib.helpers as h
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 30, in <module>
    from bleach import clean as clean_html
  File "/usr/lib/ckan/default/lib/python2.7/site-packages/bleach/__init__.py", line 8, in <module>
    from html5lib.sanitizer import HTMLSanitizer
ImportError: No module named sanitizer

What steps can be taken to reproduce the issue?

Install from source on Centos 7 64bits with python 2.7. (A very similar installation described on https://github.com/ckan/ckan/wiki/How-to-install-CKAN-2.5.2-on-CentOS-6.8)

The reason of this problem appears to be related to a recent change on html5lib, take a look on
https://github.com/mozilla/bleach/issues/212#issuecomment-233232734

CKAN 2.5.2 uses 'bleach==1.4.2', maybe upgrading the bleach version will repair it, I'll test with bleach-1.4.3 and post here a feedback.

Most helpful comment

You have to downgrade htmllib, try with this

pip install --upgrade bleach

All 3 comments

You have to downgrade htmllib, try with this

pip install --upgrade bleach

This was already reported and fixed, see #3214. The fix will be shipped with CKAN 2.5.3 and 2.6.

As @torfsen mention please use the release-v2.5.3 branch or manually upgrade to bleach==1.4.3

Was this page helpful?
0 / 5 - 0 ratings