Skip to content

obnoxious double warning at each script startup #7404

Closed

Description

@vnoel

For longer that I can remember, every time I start a script that imports matplotlib I get the following warnings:

/users/noel/.conda/envs/my_root/lib/python2.7/site-packages/matplotlib/backend_managers.py:62:
UserWarning: Treat the new Tool classes introduced in v1.5 as experimental for now, the API will likely
change in version 2.1 and perhaps the rcParam as well
 'version 2.1 and perhaps the rcParam as well')
/users/noel/.conda/envs/my_root/lib/python2.7/site-packages/matplotlib/backend_tools.py:78:
UserWarning: Treat the new Tool classes introduced in v1.5 as experimental for now, the API will likely
change in version 2.1, and some tools might change name
 'version 2.1, and some tools might change name')

These warnings are not only annoying, as I have no way to fix the code they refer to, but also lead to problems: by making the script output harder to parse, they often hide the actual output I want from the script. They are often longer than the useful script output.

I have seen suggestions to use the warning module to silence these messages, e.g.

import warnings
warnings.filterwarnings(action='ignore')

but I don't think this is a practical solution, as 1) I would need to add these two lines every time I create a new script that uses matplotlib (which is often), and 2) I would silence at the same time all the other warnings, that could be actually useful.

matplotlib 1.5.3 Python 2.7.12 on linux installed through conda, TkAgg backend.

Apparently not everyone sees those warnings.

Activity

  1. vnoel commented on Nov 4, 2016

    @vnoel
    Author

    Apparently this is related to the TkAgg backend -- switching to wxagg makes the warnings disappear.

  2. tacaswell commented on Nov 4, 2016

    @tacaswell
    Member
  3. added this to the milestone on Nov 4, 2016
  4. OceanWolf commented on Nov 4, 2016

    @OceanWolf
    Member

    @vnoel You should only see these warnings if you have opted in to using the new experimental tool classes and/or tool_manager class as the warning suggests, but your comments seem to indicate that you have not done this, so I find this perplexing.

    By opted in, I mean either by making use of these new experimental classes directly; or in-directly by setting the toolbar rcparam to toolmanager which one can do either as a line added to your script, or to one of your matplotlibrc files. Can you double check whether you have done any of these things. Another possibility arises from the usage of another library that sets this rcParam for you, but they should not have started using classes whilst still marked as experimental.

  5. vnoel commented on Nov 4, 2016

    @vnoel
    Author

    @OceanWolf AFAIK, I do not use these experimental classes directly. I have only very little idea of what they are.

    My toolbar rcparam is set to None (in ~/.config/matplotlib/matplotlibrc), as it has been for quite some time. It is however not impossible that I might have set the toolbar to toolmanager at some point in the past, but I honestly can't remember. Could that be the cause for the warnings?

    As for other libraries setting the rcParam for me, I still get the warnings by running this script:

    #!/usr/bin/env python
    import matplotlib.pyplot as plt
    plt.figure()
    

    so I don't think other libraries could be responsible.

  6. OceanWolf commented on Nov 4, 2016

    @OceanWolf
    Member

    Ahh, I see the problem, we assumed that the toolbar rcParam set to None should still use the toolmanager but without a toolbar. An assumption we should re-evaluate. Thank you for bringing this to our attention.

    Until we get this fixed, in the next bug fix release, I have three options:

    1. Use the current stable toolbar, either by removing the toolbar rcParam, or changing it to toolbar2, the current stable toolbar, both methods have the same effect.

    2. Use a different backend like wxagg.

    3. Edit the matplotlib code in matplotlib/backends/backend_tkagg.py, changing:

      def _get_toolmanager(self):
          if rcParams['toolbar'] != 'toolbar2':

      to

      def _get_toolmanager(self):
          if rcParams['toolbar'] == 'toolmanager':
  7. added a commit that references this issue on Dec 8, 2016
    7371b52
  8. modified the milestones: , on Dec 8, 2016
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions