我在导入seaborn时遇到了这个问题:

5

当我尝试在Jupyter笔记本中运行以下代码时

> import seaborn as sns     

我遇到了以下错误:
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-ed9806ce3570> in <module>()
----> 1 import seaborn as sns

~/anaconda3/lib/python3.6/site-packages/seaborn/__init__.py in <module>()
      8 from .palettes import *
      9 from .regression import *
---> 10 from .categorical import *
     11 from .distributions import *
     12 from .timeseries import *

~/anaconda3/lib/python3.6/site-packages/seaborn/categorical.py in <module>()
      5 from scipy import stats
      6 import pandas as pd
----> 7 from pandas.core.series import remove_na
      8 import matplotlib as mpl
      9 from matplotlib.collections import PatchCollection

ImportError: cannot import name 'remove_na'

以下是依赖版本:

Python 3.6.3

conda 4.8.2

numpy 1.18.0

pandas 1.0.1

scipy 1.1.0

matplotlib 3.1.3

这里有什么问题?

2个回答

4

好的,

所以我仍然不知道,在这个问题中出了什么问题,但是我解决了这个问题。

我只是简单地卸载了 seaborn。

pip3 uninstall seaborn

并重新安装它

pip3 install seaborn

这次成功了,没有出现错误。

但是我仍然不知道,第一次出错的原因。

如果有人能帮忙解决,请分享。


1
问题在于seaborn似乎正在使用pandas的私有方法。该问题已报告给pandas和seaborn开发人员(请参见https://github.com/pandas-dev/pandas/issues/16971https://github.com/mwaskom/seaborn/pull/1241),两者都在后续版本中发布了修复程序。
已修复的版本可在pip上获得,但截至2020年8月,Ubuntu的软件包尚未更新。然而,对于那些不想使用pip安装的用户,修复程序很简单,可以手动应用(请参见上面的pull request)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接