【问题标题】:how can i solve this attribute error in python?如何解决python中的这个属性错误?
【发布时间】:2021-01-10 12:25:50
【问题描述】:

运行程序时出现此属性错误。我可以知道原因吗?

AttributeError: 部分初始化的模块“seaborn”没有属性“distplot”(很可能是由于循环导入)

这是我写的代码

from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns

sns.displot(random.normal(size=1000), hist=False)

plt.show()

【问题讨论】:

  • 完整的堆栈跟踪是什么?
  • docs 表明它已被弃用。这取决于您使用的版本
  • 在你的问题中你写distplot,但在代码中你写displot(没有t)。它们是相关但不同的功能。 displot 自 Seaborn 0.11 以来是新的,它也弃用了 distplot。可能您正在运行旧版本的 Seaborn。

标签: python numpy matplotlib attributes seaborn


【解决方案1】:

你可以试试这个:

from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot(random.normal(size=1000), hist=False)

plt.show()

我修改的代码:

sns.displot(x) -> sns.distplot(o)

这是输出:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-20
    • 2013-11-18
    • 2021-10-09
    • 1970-01-01
    • 1970-01-01
    • 2022-07-01
    • 2023-04-02
    • 1970-01-01
    相关资源
    最近更新 更多