1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

scikit-learn で No module named '_bz2' というエラーがでる問題

Last updated at Posted at 2017-05-11

前提

pyenv で python 3.X をインストールしていること

エラー内容

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    from sklearn.feature_extraction.text import TfidfVectorizer
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/sklearn/__init__.py", line 57, in <module>
    from .base import clone
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/sklearn/base.py", line 12, in <module>
    from .utils.fixes import signature
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/sklearn/utils/__init__.py", line 18, in <module>
    from ..externals.joblib import cpu_count
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/sklearn/externals/joblib/__init__.py", line 122, in <module>
    from .memory import Memory, MemorizedResult
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/sklearn/externals/joblib/memory.py", line 37, in <module>
    from . import numpy_pickle
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/sklearn/externals/joblib/numpy_pickle.py", line 16, in <module>
    from .numpy_pickle_utils import _COMPRESSORS
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/site-packages/sklearn/externals/joblib/numpy_pickle_utils.py", line 12, in <module>
    import bz2
  File "/home/vagrant/.pyenv/versions/3.4.3/lib/python3.4/bz2.py", line 20, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: No module named '_bz2'

解決策

ググると

$ sudo yum install bzip2-devel

で解決とあるんだけど、これをした上で、python そのものをインストールしなおす必要がある。

$ pyenv install 3.4.3
$ pyenv global 3.4.3

で動くようになる。

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?