Skip to content

Custom datapath deprecated in v3.2.0 without warning #16678

Closed

Description

@eniemela3

Bug report

Bug summary

I have a large-ish tkinter/matplotlib application where I have defined a custom datapath in a matplotlibrc file in my current working directory. I recently updated matplotlib to v3.2.0 from v3.1.3, and my custom datapath is no longer being used. I noticed this was deprecated in 4833d99. However, I am not seeing the deprecation warning, as the "mpl-data" directory is also found and returned in the lines right above the deprecation warning. The problem surfaces when the custom data I had stored in my datapath is not found in the default path, and my application crashes.

If custom datapaths can no longer be used, could it be removed from the sample matplotlibrc file? (https://matplotlib.org/3.2.0/tutorials/introductory/customizing.html#a-sample-matplotlibrc-file)

Also, what is the recommended way of handling custom data, in my case, a handful of gifs? The commit mentions that

Note that redistributors (e.g. linux distro packagers) who may want to move mpl-data out can still do so by patching out the entire _get_data_path function.

but I'd rather not do that as it might break again soon with an update.

Code for reproduction

The following code will not reproduce the actual scenario where I encountered the error, but it shows that the custom datapath is not used and no deprecation warnings are displayed.

An empty datapath folder and a matplotlibrc file in the working directory, with the line

#datapath : /home/jdhunter/mpldata

uncommented and set to your datapath folder.

>>> import matplotlib.pyplot as plt
>>> plt.plot([1, 1, 1])
>>> plt.show()

Actual outcome

The plot is shown, so the custom datapath was not used, but no deprecation warnings are shown.

Expected outcome

The following was output on v3.1.3, where the custom datapath was used and it obviously did not contain the needed files resulting in an error:

_tkinter.TclError: couldn't open "ggg\images\matplotlib.ppm": no such file or directory

Matplotlib version

  • Operating system: Microsoft Windows 10 Pro Version 1909
  • Matplotlib version: 3.2.0 (pip installed)
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.7.5

Activity

  1. anntzer commented on Mar 5, 2020

    @anntzer
    Contributor

    The rcparam is getting deprecated in #16417, but I missed the fact that I should have targeted it for 3.2. Sorry about the disruption, I'll remilestone that PR as 3.2.1.

    From your error message, I assume you are trying to set your own icons? I would suggest that you simply ship your own ppm files whereever you want, let matplotlib initially set its own icon, and then later set the icons with your own tk calls. (In other words, I don't think shipping your own mpl-data should be considered public API for overwriting the icons; if there's really demand for that I'd rather have a less convoluted way to do so.) Or are you trying to do other things with mpl-data?

  2. added this to the v3.2.1 milestone on Mar 5, 2020
  3. eniemela3 commented on Mar 5, 2020

    @eniemela3
    Author

    Thanks for the quick reply!

    Yes, I am trying to set my own icons. This problem originally came up in a in a custom toolbar with custom icons that is based on NavigationToolbar2Tk. I followed along this Stack Overflow thread
    and simply set the toolitems to something along the lines of ('text', 'tooltip', 'gif', 'callback'), where the gif was located in my own datapath. They're the only icons I'm using in my application, so I don't need the default mpl-data at all. Do you think there would still be a way to use custom images with this approach?

  4. anntzer commented on Mar 5, 2020

    @anntzer
    Contributor

    You can; I think you "just" need to grab the native tk widgets and perform the right calls to iconphoto() and friends on them.

  5. eniemela3 commented on Mar 6, 2020

    @eniemela3
    Author

    Thanks, I'll try that out!

  6. tacaswell commented on Mar 10, 2020

    @tacaswell
    Member

    @anntzer I don't understand what about that change made us ignore the rcparam though.

  7. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    and removed on Mar 10, 2020
  8. anntzer commented on Mar 10, 2020

    @anntzer
    Contributor

    Because in #14401 I assumed that people would be using get_data_path(), but I missed the fact that they could also use rcParams["datapath"].

  9. tacaswell commented on Mar 11, 2020

    @tacaswell
    Member

    #14104 is the change that actually broke this.

  10. added 2 commits that reference this issue on Mar 13, 2020
    5f62526
    ecd95c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions