Error when creating Database Tables - CKAN
Question: i'm trying to install CKAN 2.5.2 on Centos 6.8

When i run paster db init -c /etc/ckan/default/development.ini

i get error

    
    
    Traceback (most recent call last):
      File "/usr/lib/ckan/default/bin/paster", line 9, in <module>
        load_entry_point('PasteScript==2.0.2', 'console_scripts', 'paster')()
      File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/script/command.py", line 102, in run
        invoke(command, command_name, options, args[1:])
      File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/script/command.py", line 141, in invoke
        exit_code = runner.run(args)
      File "/usr/lib/ckan/default/lib/python2.6/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.6/site-packages/paste/deploy/loadwsgi.py", line 261, in appconfig
        global_conf=global_conf)
      File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
        global_conf=global_conf)
      File "/usr/lib/ckan/default/lib/python2.6/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.6/site-packages/paste/deploy/loadwsgi.py", line 454, in get_context
        section)
      File "/usr/lib/ckan/default/lib/python2.6/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.6/site-packages/paste/deploy/loadwsgi.py", line 406, in get_context
        global_conf=global_conf)
      File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
        global_conf=global_conf)
      File "/usr/lib/ckan/default/lib/python2.6/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.6/site-packages/paste/deploy/loadwsgi.py", line 620, in get_context
        object_type, name=name)
      File "/usr/lib/ckan/default/lib/python2.6/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.6/site-packages/pkg_resources/__init__.py", line 2229, in load
        return self.resolve()
      File "/usr/lib/ckan/default/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2235, 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.6/site-packages/bleach/__init__.py", line 8, in <module>
        from html5lib.sanitizer import HTMLSanitizer
    ImportError: No module named sanitizer
    

I was following [wiki instructions](https://github.com/ckan/ckan/wiki/How-to-
install-CKAN-2.5.2-on-CentOS-6.8)

I'm stuck on this step and don't know how to proceed.

Module html5lib is imported and updated to latest version. Paster script is
executed in virtualenv under root account.

Also i'm running all of this in python2.6 since that is default on Centos.

Some additional information

when i run python and import html5lib and then help(html5lib) i get this

    
    
    >>> import html5lib
    >>> help(html5lib)
    Help on package html5lib:
    
    NAME
        html5lib
    
    FILE
        /usr/lib/python2.6/site-packages/html5lib/__init__.py
    
    DESCRIPTION
        HTML parsing library based on the WHATWG "HTML5"
        specification. The parser is designed to be compatible with existing
        HTML found in the wild and implements well-defined error recovery that
        is largely compatible with modern desktop web browsers.
    
        Example usage:
    
        import html5lib
        f = open("my_document.html")
        tree = html5lib.parse(f)
    
    PACKAGE CONTENTS
        _ihatexml
        _inputstream
        _tokenizer
        _trie (package)
        _utils
        constants
        filters (package)
        html5parser
        serializer
        treeadapters (package)
        treebuilders (package)
        treewalkers (package)
    
    CLASSES
        __builtin__.object
            html5lib.html5parser.HTMLParser
    
        class HTMLParser(__builtin__.object)
         |  HTML parser. Generates a tree structure from a stream of (possibly
         |  malformed) HTML
         |
         |  Methods defined here:
    :
    

There is no sanitizer here. Do i need to use specific version of html5lib?

Can anyone help?


Answer: It looks like you have 2 copies of html5lib installed. When you did
help(html5lib) it is showing a copy that is installed in your user's python
directory (/usr/lib/python2.6/site-packages/) not the virtualenv that you have
ckan (and bleach) installed (/usr/lib/ckan/default/lib/python2.6/site-
packages/). So get rid of the former to avoid confusion.

Yes I think you have the wrong version of html5lib, since sanitizer is listed
in the package contents when I do help.

This is the correct version (at the time of writing - in future check what is
in requirements.txt):

    
    
    $ pip freeze | grep html5lib
    html5lib==0.9999999
    

