>>> 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'
我知道还有很多其他类似的问题,但没有一个有帮助。我试过重新安装熊猫:
sudo pip3 uninstall pandas
sudo pip3 install pandas
我还确保已将以下内容添加到我的 bash 配置文件中:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
原文由 an0therlurker 发布,翻译遵循 CC BY-SA 4.0 许可协议
问题出在pandas package api的变化上
如 0.23 https://pandas.pydata.org/pandas-docs/version/0.23/api.html?highlight=compat
和 0.24 https://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
你可以使用
解决这个问题,它对我有用