Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package

When I tried to read a pickle file that saved by a former version of pandas, it yielded an ImportError.

ImportError: No module named 'pandas.core.internals.managers'; 'pandas.core.internals' is not a package

There was no hit on stackoverflow so i would like to share my solution for this particular problem.

like image 573
Fatih1923 Avatar asked Feb 13 '19 08:02

Fatih1923


5 Answers

This error comes off due to encoding of formerly saved pickle file. If you updated pandas to newly amended version, it produces this import error.

like image 159
Fatih1923 Avatar answered Oct 23 '22 15:10

Fatih1923


I was facing the same error when I was using pandas version 0.23.4.

I have installed pandas 0.24.1 version explicitly by:

pip3 install pandas==0.24.1

This solved my problem(Python version I was using was 3.5)

like image 33
Chandan Avatar answered Oct 23 '22 15:10

Chandan


I had the same problem, but for me, it seemed to come from the pickle package / interaction with the pandas package.

I had Pandas version 0.23.4. I saved some pickle files with pandas.Dataframe.to_pickle, with python 3.6.6 & Pandas version 0.23.4. Then I upgraded to python 3.7.2 (Pandas version 0.23.4), and was enabled to read thoses pickle files with pandas.Dataframe.read_pickle. Next, I upgraded pandas to pandas 0.24.1, and it worked for me. I can read those files again.

like image 10
Charles dc Avatar answered Oct 23 '22 14:10

Charles dc


Updating pandas would be the best solution for most cases. However if you have limitations updating your pandas version, and you need to consume pandas objects produced and pickled in a higher version, you can add class location map as below.

from pandas.compat.pickle_compat import _class_locations_map

_class_locations_map.update({
    ('pandas.core.internals.managers', 'BlockManager'): ('pandas.core.internals', 'BlockManager')
})
like image 7
Gengyu Shi Avatar answered Oct 23 '22 15:10

Gengyu Shi


conda update pandas

If you use conda package manager.

like image 2
Bstampe Avatar answered Oct 23 '22 13:10

Bstampe