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

mfuanj7w  于 2022-12-02  发布在  Python
关注(0)|答案(2)|浏览(156)

我已经安装了libbz 2-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
ohfgkhjo

ohfgkhjo1#

你可以试着做

pip install bz2file
owfi6suc

owfi6suc2#

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

sudo apt-get install libbz2-dev

相关:missing python bz2 module

相关问题