>>> import pandas
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import pandas
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas/__init__.py", line 40, in <module>
import pandas.core.config_init
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas/core/config_init.py", line 14, in <module>
import pandas.core.config as cf
File
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/pandas/core/config.py", line 57, in <module>
import pandas.compat as compat
AttributeError: module 'pandas' has no attribute 'compat'
我知道还有很多其他类似的问题,但没有一个有帮助。我尝试过重新安装 pandas:
sudo pip3 uninstall pandas
sudo pip3 install pandas
我还确保已将以下内容添加到我的 bash 配置文件中:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
问题出在 pandas 包 api 的改变上
Warning
The pandas.core, pandas.compat, and pandas.util top-level modules are PRIVATE. Stable functionality in such modules is not guaranteed.
如0.23https://pandas.pydata.org/pandas-docs/version/0.23/api.html?highlight=compat
并在 0.24https://pandas.pydata.org/pandas-docs/version/0.24/reference/index.html
并且稳定(现在0.25)https://pandas.pydata.org/pandas-docs/stable/reference/index.html?highlight=compat
你可以使用
pip uninstall pandas
pip install --upgrade pandas==0.23.0
要解决这个问题,它对我有用
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)