简体   繁体   中英

Python import error no module named bz2

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

你可以尝试做

pip install bz2file

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM