0

I have libbz2-dev installed however I am still getting the following import error while importing 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
aradhyamathur
  • 340
  • 7
  • 21
  • Did you checked following post? Was it helpful? http://stackoverflow.com/a/12806325/4518277 – Xyrus Jul 28 '16 at 08:50

2 Answers2

1

I'm having the same issue and the tip above didn't resolve it. Perhaps before creating the virtual env you need to:

sudo apt-get install libbz2-dev

related: missing python bz2 module

dcsan
  • 11,333
  • 15
  • 77
  • 118
0

you can try to do

pip install bz2file
Arnaud Wurmel
  • 480
  • 3
  • 15
  • 1
    i did try that did not work. I had to reinstall python recreate virtualenv and it got resolved. Still don't know what might have caused it. – aradhyamathur Jul 28 '16 at 21:15