将 pandas 导入 Jupyter notebook 时出错

Error when importing pandas to Jupyter notebook

我正在尝试将 pandas 导入 Jupyter notebook 并收到以下错误:

ImportError: cannot import name 'DtypeArg' from 'pandas._typing' (/Users/YA/opt/anaconda3/lib/python3.7/site-packages/pandas/_typing.py)

到目前为止,我的代码实际上只有一行:import pandas as pd。请帮助我了解发生了什么。谢谢!

在常规终端中尝试以下选项(而不是在 Jupyter 笔记本或 Jupyter 终端中)

选项 1:

pip uninstall pandas
pip install pandas --upgrade

选项 2

pip install pandas==1.1.5

来源:

https://github.com/pandas-dev/pandas/issues/42506#issuecomment-878501500