Pandas: cannot import name compat
You didn't tell us your pandas version, for 0.25,0.24,0.23 as the doc says about pandas.compat
Warning
The pandas.core, pandas.compat, and pandas.util top-level modules are PRIVATE. Stable functionality in such modules is not guaranteed.
as in 0.23 https://pandas.pydata.org/pandas-docs/version/0.23/api.html?highlight=compat
it seems that downgrade to 0.23 works for me. you may use
pip uninstall pandas
pip install --upgrade pandas==0.23.0
and in 0.24 https://pandas.pydata.org/pandas-docs/version/0.24/reference/index.html
and in stable(Now 0.25) https://pandas.pydata.org/pandas-docs/stable/reference/index.html?highlight=compat
Vedang Waradpande
Updated on June 04, 2022Comments
-
Vedang Waradpande almost 2 years
I have some code,
preprocess_align.py
which runs perfectly on my PC but I get anImportError
when running it on a server. TheImportError
supposedly comes whenpandas
is imported. Here is the error:Traceback (most recent call last): File "get_features.py", line 12, in <module> import preprocess_align as prep File "/home/influenza/preprocess_align.py", line 7, in <module> import pandas as pd File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/__init__.py", line 42, in <module> from pandas.core.api import * File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/core/api.py", line 10, in <module> from pandas.core.groupby.groupby import Grouper File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/core/groupby/__init__.py", line 2, in <module> from pandas.core.groupby.groupby import ( File "/home/influenza/anaconda2/lib/python2.7/site-packages/pandas/core/groupby/groupby.py", line 16, in <module> from pandas import compat ImportError: cannot import name compat
The Python version is
Python 2.7.14 |Anaconda custom (64-bit)
and I have already usedconda update pandas
to update the version to the latest.Any help is appreciated.
-
m33n over 5 yearsCan you uninstall pandas and reinstall it again? I know it sounds classic but I remembered that worked for me
-
Pierre Delecto over 5 yearsI am experiencing the same issue. I have tried updating nltk as well as uninstalling and reinstalling pandas with no success.
-
Pierre Delecto over 5 yearsAfter reopening my IDE (Spyder) the problem was solved.
-
aunsid over 4 yearsI has the same issue and I solved it by reinstalling pandas. Since the OP has mentioned that he is using conda. for Uninstallation conda remove --force pandas. Installing it back again conda install -c anaconda pandas