The problem that scikit-learn gives the error No module named'_bz2'

Premise

You have python 3.X installed with pyenv

error contents

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'

solution

When you google

$ sudo yum install bzip2-devel

There is a solution in, but after doing this, you need to reinstall python itself.

$ pyenv install 3.4.3
$ pyenv global 3.4.3

Will work with.

Recommended Posts

The problem that scikit-learn gives the error No module named'_bz2'
ModuleNotFoundError: No module named'_bz2' error in pyenv Python
When I try to import pandas on macOS I get the error No module named'_bz2'
Solved the problem that sqlite3 got undefined error when cross-compiling Golang
Python error: ModuleNotFoundError: No module named'flask'
I get a Python No module named'encodings' error with the aws command
Today's python error: ModuleNotFoundError: No module named
Today's python error: ModuleNotFoundError: No module named
Today's python error: ModuleNotFoundError: No module named'requests'
Today's python error: ModuleNotFoundError: No module named'bs4'
Import Error in Python3: No module named'xxxxx'
Solution for "Import Error: No module named requests"
About the matter that was worried about sampling error
The problem that the ifconfig command cannot be used