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

【报错】使用 AutoDL 下 Notebook 调用 matplotlib 时遇到 AttributeError: module 'matplotlib' has no attribute 'get_data_path' 报错:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_1156/517952973.py in <module>
      2 import skimage
      3 import IPython.display
----> 4 import matplotlib.pyplot as plt
      5 from PIL import Image
      6 import numpy as np

~/miniconda3/lib/python3.8/site-packages/matplotlib/__init__.py in <module>
    821 # triggering resolution of _auto_backend_sentinel.
    822 rcParamsDefault = _rc_params_in_file(
--> 823     cbook._get_data_path("matplotlibrc"),
    824     # Strip leading comment.
    825     transform=lambda line: line[1:] if line.startswith("#") else line,

~/miniconda3/lib/python3.8/site-packages/matplotlib/cbook/__init__.py in _get_data_path(*args)
    532     ``*args`` specify a path relative to the base data path.
    533     """
--> 534     return Path(matplotlib.get_data_path(), *args)
    535 
    536 

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

【原因】上文安装的库重新安装了指定版本的 matplotlib 库,安装完成后没有重启。

【解决办法】重启内核即可 1

在这里插入图片描述


  1. AttributeError: module ‘matplotlib’ has no attribute ‘get_data_path’ when running result.plot() ↩︎

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
AttributeError: module 'matplotlib' has no attribute 'get_data_path'表示在使用matplotlib模块时,出现了找不到'get_data_path'这个属性的错误。要解决这个问题,可以尝试以下方法: 1. 检查matplotlib版本:确保你使用的是最新的matplotlib版本。你可以通过运行以下命令来升级matplotlib:`pip install --upgrade matplotlib`。 2. 检查引用:请确保你正确地引用了matplotlib模块。通常,应该使用`import matplotlib.pyplot as plt`来引用matplotlib并使用plt来调用其相关函数。 3. 检查安装:如果你已经安装了matplotlib库,但仍然出现此错误,请尝试重新安装matplotlib。你可以使用以下命令来卸载和重新安装matplotlib:`pip uninstall matplotlib`,然后`pip install matplotlib`。 如果你的问题是关于seq_loss.py文件中的另一个错误,即AttributeError: module 'tensorflow.compat.v1' has no attribute 'contrib',请确保你使用的是与该文件兼容的tensorflow版本。在较新的tensorflow版本中,"contrib"模块已被移除,因此你可能需要更新你的代码以适应最新版本的tensorflow。 请注意,在代码中的修改或更改版本之前,建议先备份代码,并仔细检查错误消息以确定确切的问题所在。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [AttributeError: modulematplotlib’ has no attribute ‘figure’](https://blog.csdn.net/xingleitinghai/article/details/125359390)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [AttributeError: module 'tensorflow.compat.v1' has no attribute '](https://download.csdn.net/download/qq_38766019/86272235)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值