如何解决这个 Python AttributeError: module 'matplotlib' has no attribute 'get_data_path'(在 JupyterLab 3.0>=) [英] How to solve this Python AttributeError: module 'matplotlib' has no attribute 'get_data_path' (in JupyterLab 3.0>=)

查看:334
本文介绍了如何解决这个 Python AttributeError: module 'matplotlib' has no attribute 'get_data_path'(在 JupyterLab 3.0>=)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Today(Mar 30, 2021) I upgraded matplotlib and seaborn package.

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

But, after that, I can't import matplotlib and seaborn package.

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

Whenever I tried importing matplotlib or seaborn, I got error messages like below.

我该如何解决这个问题?

How can I solve this problem?

(我使用的是 JupyterLab 3.0)

(I used JupyterLab 3.0)

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

C:devanaconda3libsite-packagesmatplotlib\__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:devanaconda3libsite-packagesmatplotlibcbook\__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'

推荐答案

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

These kinds of errors are typical for a version conflict, especially if you recently upgraded.

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

A common mistake is to just upgrade one package and expect that everything else will continue to work. Certain versions of libraries are only compatible with certain versions of other libraries and so on. Reality is that you have to find a working combination of all the libraries as a whole. From your example it is impossible to know what went wrong, but I would assume that you also have to upgrade the maptplotlib dependencies, and possibly their dependencies too.

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

If you are not closely familiar with those libraries, it can get tricky to chase this down, so you might be better off by simply reinstalling everything through pip or some other dependency-aware package manager.

这篇关于如何解决这个 Python AttributeError: module 'matplotlib' has no attribute 'get_data_path'(在 JupyterLab 3.0>=)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆