Skip to content

obnoxious double warning at each script startup #7404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vnoel opened this issue Nov 4, 2016 · 5 comments
Closed

obnoxious double warning at each script startup #7404

vnoel opened this issue Nov 4, 2016 · 5 comments
Milestone

Comments

@vnoel
Copy link

vnoel commented Nov 4, 2016

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.

@vnoel
Copy link
Author

vnoel commented Nov 4, 2016

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

@tacaswell
Copy link
Member

attn @OceanWolf @fariza

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Nov 4, 2016
@OceanWolf
Copy link
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.

@vnoel
Copy link
Author

vnoel commented Nov 4, 2016

@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.

@OceanWolf
Copy link
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':

@NelleV NelleV closed this as completed in ba019f7 Nov 8, 2016
QuLogic pushed a commit that referenced this issue Dec 8, 2016
FIX: MPL should not use new tool manager unless explicited asked for.  Closes #7404
@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants