Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error using pelican-quickstart "No module named html_parser"

Tags:

python

pelican

I decided to give pelican a try, but when I run pelican-quickstart, I get the following dialog:

$ pelican-quickstart
Traceback (most recent call last):
  File "/usr/local/bin/pelican-quickstart", line 9, in <module>
    load_entry_point('pelican==3.4.0', 'console_scripts', 'pelican-quickstart')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 357, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2394, in load_entry_point
return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2108, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Library/Python/2.7/site-packages/pelican-3.4.0-py2.7.egg/pelican/__init__.py", line 20, in <module>
from pelican.generators import (ArticlesGenerator, PagesGenerator,
  File "/Library/Python/2.7/site-packages/pelican-3.4.0-py2.7.egg/pelican/generators.py", line 23, in <module>
from pelican.readers import Readers
  File "/Library/Python/2.7/site-packages/pelican-3.4.0-py2.7.egg/pelican/readers.py", line 24, in <module>
from six.moves.html_parser import HTMLParser
ImportError: No module named html_parser `

There was a similar error message in this post, and since I'm running Python 2.7.6 on OS X 10.10 (Yosemite), there may be a similar issue.

What's the best way to address this?

like image 362
alspur Avatar asked Oct 22 '14 13:10

alspur


3 Answers

Reinstall Pelican doesn't help me, so I made a little fix in pelican

Modifications were made in following file

/Library/Python/2.7/site-packages/pelican/readers.py

at line 24 place

from six.moves import html_parser

instead of

from six.moves.html_parser import HTMLParser

and at line 299

    class _HTMLParser(html_parser.HTMLParser):

instead of

    class _HTMLParser(HTMLParser):

Modification actual for pelican 3.6.0, but seems to applicable for other version if search for this lines in readers.py file. This is just quick workaround, hope this problem will be solved at pelican's side.

like image 148
Alexey Sviridov Avatar answered Oct 24 '22 11:10

Alexey Sviridov


This error seems to come from Python 2.7.6 on OSX. When I install python via Homebrew and reinstall this module I got rid of this error.

$ pip uninstall pelican
$ brew install python
$ which python # should show /usr/local/bin/python
$ python -V # should show Python 2.7.8
$ pip install pelican
like image 31
David Rasch Avatar answered Oct 24 '22 11:10

David Rasch


I think that you've probably encountered with version conflict problem in module six.

Try sudo pip install virtualenv to create an isolate python environment.

start

  1. create your pelican path mkdir /path/to/pelican
  2. go to /path/to/pelican and create an isolate python environment with virtualenv venv
  3. activate virtualenv source venv/bin/activate
  4. install pelican under the venv(without sudo!) pip install pelican markdown

done

and now you are free to any problem mentioned above. all the dependencies in the venv are isolated from the global environment.

To quit the venv, type deactivate

like image 33
alwinlin Avatar answered Oct 24 '22 11:10

alwinlin