python3 - No module named 'html5lib'

Steven D'Aprano steve at pearwood.info
Thu Apr 14 07:47:03 EDT 2016


On Thu, 14 Apr 2016 07:31 pm, Sergio Spina wrote:

> I'm running a python3 program that requires html5lib but I receive the
> error No module named 'html5lib'.
> 
> Here are two session of terminal:
> 
>     sam at pc ~ $ python
>     Python 2.7.9 (default, Mar  1 2015, 12:57:24)
>     [GCC 4.9.2] on linux2
>     >>> import html5lib
>     >>> html5lib.__file__
>     '/usr/local/lib/python2.7/dist-packages/html5lib/__init__.pyc'
>     >>> quit()

You have installed html5lib as a library for Python 2.7.

Or possibly your Linux distribution has installed it.


>     sam at pc ~ $ python3
>     Python 3.4.2 (default, Oct  8 2014, 10:45:20)
>     [GCC 4.9.1] on linux
>     >>> import html5lib
>     Traceback (most recent call last):
>       File "<stdin>", line 1, in <module>
>     ImportError: No module named 'html5lib'
> 
> Where can be the problem?

Python 3 has its own set of libraries, and doesn't automatically use the
Python 2 libraries.

My guess is that if you installed html5lib using yum or apt-get, there will
be a similar command that will install the Python 3 version.



-- 
Steven




More information about the Python-list mailing list