Monday, 28 August 2023

Pandas and pandasgui show leads to ImportError

According to the pandasgui docs I tried to run the following code:

import pandas as pd
from pandasgui import show
df = pd.DataFrame({'a':[1,2,3], 'b':[4,5,6], 'c':[7,8,9]})
show(df)

However, I get an error:

ImportError: cannot import name '_c_internal_utils' from partially initialized module 'matplotlib' (most likely due to a circular import) (c:\Users\Shayan\ypy1\lib\site-packages\matplotlib\__init__.py)

According to this post it seems related to the fact that pands and pandasgui import statements both use the same reference to a matploblib function/module, so there is a circular import. I tried to change the code to

import pandas as pd
import pandasgui
df = pd.DataFrame({'a':[1,2,3], 'b':[4,5,6], 'c':[7,8,9]})
pandasgui.show(df)

But I get the same error. How can I fix this?

My python is version 3.11.4 | packaged by Anaconda, Inc.

My pandas is version 2.03 it was already installed in my anaconda environment by default and I updated it with the Anaconda navigator.

My pandasgui is version 0.2.14 and I installed it with pip install pandasgui. I updated the index in Anaconda navigator and it also displays version 0.2.14



from Pandas and pandasgui show leads to ImportError

No comments:

Post a Comment