作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我上周将我的机器升级到了 Yosemite。现在,当尝试运行 pelican devserver 时,我得到一个 ImportError:
$ ./develop_server.sh start
Starting up Pelican and HTTP server
Traceback (most recent call last):
File "/usr/local/bin/pelican", line 7, in <module>
from pelican import main
File "/Library/Python/2.7/site-packages/pelican/__init__.py", line 20, in <module>
from pelican.generators import (ArticlesGenerator, PagesGenerator,
File "/Library/Python/2.7/site-packages/pelican/generators.py", line 23, in <module>
from pelican.readers import Readers
File "/Library/Python/2.7/site-packages/pelican/readers.py", line 24, in <module>
from six.moves.html_parser import HTMLParser
ImportError: No module named html_parser
/usr/bin/python: No module named html_parser
Pelican didn't start. Is the Pelican package installed?
Stale PID, deleting
Stale PID, deleting
我在尝试直接导入时从 REPL 得到了同样的错误,但模块已安装:
$ /usr/bin/python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import
KeyboardInterrupt
>>> from six.moves.html_parser import HTMLParser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named html_parser
>>> import six
>>> six.moves.html_parser
<module 'HTMLParser' from '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.pyc'>
>>> six.moves.html_parser.HTMLParser
<class HTMLParser.HTMLParser at 0x10b751530>
>>>
我是否遗漏了一些明显的东西?这是怎么回事?
最佳答案
这六个库使用了一些高级的导入魔法。 html_parser
的导入必须以特殊方式完成。 from six.moves import html_parser
通常有效。如果您有第三方代码尝试以其他方式从 6 导入,您可以在导入任何其他内容之前先尝试导入 six
和/或 six.moves
。
关于python - 为什么我会收到 python ImportError : No module named html_parser?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26691973/
我是一名优秀的程序员,十分优秀!