Issue
I am using Python 3.9.13. I installed scikit-learn from the terminal:
pip install scikit-learn
Then I tried to download the mnist dataset using fetch_openml
:
from sklearn.datasets import fetch_openml
raw_data = fetch_openml('mnist_784')
That gave me a long error message ending with:
fetch_openml with as_frame=True requires pandas.
However, I had pandas
installed. So I looked more deeply inside the error message and I found that the exception causing that error was this:
ModuleNotFoundError: No module named '_bz2'
Solution
I looked around and found a solution in this thread.
I only had to add another step to that solution.
After installing libbz2-dev
I only had _bz2.cpython-38-x86_64-linux-gnu.so
on my computer which is used for python 3.8.x so it did not work with my version of python.
I changed the file's name to _bz2.cpython-39-x86_64-linux-gnu.so
and it worked after that.
sudo apt-get install libbz2-dev
sudo cp /usr/lib/python3.8/lib-dynload/_bz2.cpython-38-x86_64-linux-gnu.so /usr/local/lib/python3.9/
sudo mv /usr/local/lib/python3.9/_bz2.cpython-38-x86_64-linux-gnu.so /usr/local/lib/python3.9/_bz2.cpython-39-x86_64-linux-gnu.so
Answered By - Saphira
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.