0

In python3.6, when executing the following command:

from sklearn.model_selection import GridSearchCV

Reported Error:

from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'

However, issue is that I don't have root access to machine to use the solutions posted on the same issue on stackoverflow.

On trying to locate libbz2.so, I received following:

/usr/lib64/libbz2.so.1
/usr/lib64/libbz2.so.1.0.6

To be noted: in my bash_profile the LIBRARY_PATH did not have '/usr/lib64' explicitly specified when I compiled python3.6 from source.

1
  • Side-note: using virtual-environments you should be able to install those non-system libraries without any problem (assuming venv is available). Commented Jul 19, 2017 at 21:38

1 Answer 1

3

bz2 is an optional dependency of python, but sklearn assumes your python installation has this module.

There are at least two possible ways to fix this:

  1. update your version of joblib to make its dependence on bz2 optional. (Thanks to sascha for pointing this out.)
  2. or, install libbz2 and then re-build python3.6.
Sign up to request clarification or add additional context in comments.

6 Comments

From that issue in this link, it sounds like installing a new version of joblib (> 10/2016) might be enough.
@unutbu: I added some more info. Can you comment on it?
@SuJK I highly recommend going for approach 1 (update joblib) first. Foreseeing all the consequences of building python yourself (if it's one global install, you might destroy system-dependencies) seems hard. Also your non-root access should stand in the way.
@SuJK: If you do want bz2 enabled in python, I believe this is the way to do it (for linux). Be sure to read the comment about make clean too.
@SuJK: You may also need to pass ./configure an option to specify where to find libbz2. Run ./configure --help to find the right option.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.