【问题标题】:How to solve this Python AttributeError: module 'matplotlib' has no attribute 'get_data_path' (in JupyterLab 3.0>=)如何解决这个 Python AttributeError: module 'matplotlib' has no attribute 'get_data_path' (in JupyterLab 3.0>=)
【发布时间】:2023-03-28 19:31:01
【问题描述】:

今天(2021 年 3 月 30 日)我升级了 matplotlib 和 seaborn 包。

但是,在那之后,我无法导入 matplotlib 和 seaborn 包。

每当我尝试导入 matplotlib 或 seaborn 时, 我收到如下错误消息。

我该如何解决这个问题?

(我使用的是 JupyterLab 3.0)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-33-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt

C:\dev\anaconda3\lib\site-packages\matplotlib\__init__.py in <module>
    819 # triggering resolution of _auto_backend_sentinel.
    820 rcParamsDefault = _rc_params_in_file(
--> 821     cbook._get_data_path("matplotlibrc"),
    822     # Strip leading comment.
    823     transform=lambda line: line[1:] if line.startswith("#") else line,

C:\dev\anaconda3\lib\site-packages\matplotlib\cbook\__init__.py in _get_data_path(*args)
    478     if opened:
    479         with fh:
--> 480             yield fh
    481     else:
    482         yield fh

AttributeError: module 'matplotlib' has no attribute 'get_data_path'

【问题讨论】:

    标签: python matplotlib seaborn attributeerror


    【解决方案1】:

    这些类型的错误是版本冲突的典型错误,尤其是在您最近升级的情况下。

    一个常见的错误是只升级一个软件包并期望其他所有软件包都能继续工作。某些版本的库仅与某些版本的其他库兼容,依此类推。现实情况是您必须找到一个所有库作为一个整体的有效组合。从您的示例中不可能知道出了什么问题,但我假设您还必须升级 maptplotlib 依赖项,可能还有它们的依赖项。

    如果您对这些库不是很熟悉,追查这些可能会很棘手,因此您最好通过 pip 或其他一些依赖关系感知包管理器重新安装所有内容。

    【讨论】:

      猜你喜欢
      • 2023-02-17
      • 1970-01-01
      • 2022-10-19
      • 2022-12-01
      • 2020-11-02
      • 2021-04-06
      • 2022-12-04
      • 2022-11-11
      • 2019-01-08
      相关资源
      最近更新 更多