Python导入错误没有名为bz2的模块

时间:2016-07-28 08:16:10

标签: python gensim

我安装了libbz2-dev但是在导入gensim时我仍然遇到以下导入错误:

>>> import gensim
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/krishna/gensimenv/lib/python2.7/site-packages/gensim/__init__.py", line 6, in <module>
    from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization
  File "/home/krishna/gensimenv/lib/python2.7/site-packages/gensim/corpora/__init__.py", line 14, in <module>
    from .wikicorpus import WikiCorpus
  File "/home/krishna/gensimenv/lib/python2.7/site-packages/gensim/corpora/wikicorpus.py", line 21, in <module>
    import bz2
ImportError: No module named bz2

2 个答案:

答案 0 :(得分:1)

你可以尝试

pip install bz2file

答案 1 :(得分:0)

我有同样的问题,上面的提示并没有解决它。 也许在创建虚拟环境之前,您需要:

sudo apt-get install libbz2-dev

相关: missing python bz2 module