-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
matplotlib 3 pyplot on MacOS bounces rocket icon in dock #12188
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
Comments
import matplotlib.pyplot
with matplotlib 3 on MacOS always put rocket icon in dockimport matplotlib.pyplot
with matplotlib 3 on MacOS always bounces rocket icon in dock
import matplotlib.pyplot
with matplotlib 3 on MacOS always bounces rocket icon in dock
No, I don't think it's that. Python and matplotlib are running just fine with the icon in the dock. (Aside: I do think I've separately encountered the font search issue, however -- when diagnosing this, I tried to remove my |
Perhaps I should ask if anyone else on MacOS is (or isn't) seeing this behaviour? |
See also this post from Dr Drang regarding Python 2.7 in 2014, although I think the icon doesn't bounce in that case. Note that the plist hack still works, but But this brings up another question: I don't see this behaviour under Python 2.7. I can get a non-bouncing icon in the dock if I set to a GUI backend, but never a bouncing icon (and no icon if I have a non-GUI backend). |
I have the same problem. The rocket icon starts bouncing after importing matplotlib.pyplot only if I upgrade from matplotlib==2.2.2 to matplotlib==3.0.0. |
This is somewhat confusing as Matplotlib 3.0.0 does not run under python 2.7. So did you mean Matplotlib 2.2.x doesn't bounce? I have a Mac and I never see the rocket icon after I set my backend to Qt5Agg. Have you tried setting this in This'll be hard for me to debug - I use conda for my install, not python.org + pip. If you go that route, its entirely possible there are mismatched libraries, and you should consider upgrading all the non-python dependencies... Sorry to not be more helpful. |
To be clear:
|
That is hard to understand, and my guess is that its always choosing the same backend, depsite your intentions Can you put import matplotlib
print(matplotlib.get_backend()) at the top of your script and check that its really giving the intended backend? |
Yep:
bounce - bounce - bounce |
I can confirm that with Python 3 and Matplotlib 2.2.2 the icon does not show up. |
@defjaf Sorry, I can't reproduce conda py3.7, mpl3.0.0. I don't get any icons in the doc until I do plt.show(). Must be something funky w. the framework build. |
@jklymak So does that mean "wontfix" or do we need to dig further? |
Oh no absolutely not. It means I probably won’t fix, but hopefully someone on the dev team uses non-conda on a Mac. Do you ever get the prompt back? Can you check backend after you get the prompt back? |
@jklymak Aha, I think there's a misunderstanding: the bouncing icon does not hang the interpreter. The prompt returns immediately and it runs just fine. |
@tacaswell @anntzer is it possible the new backend code is importing and checking a backend before accepting the OP's choice of "Agg"? |
if you do If you start a fresh interpreter can you do: import matplotlib
dict.__getitem(matplotlib.rcParams, 'backend') (which side steps the auto-fallback logic) To check, One possible concern is that the osx backend is importing just enough to trigger the rocket, but not enough to be selected? It may also help to put some print statements in the @defjaf Thanks for sticking with us to sort this out! |
bounce - bounce - bounce ... (And indeed if I actually use matplotlib I don't get a GUI.) Also, FYI, no difference in behaviour if I set |
OK, my appologies - I can reproduce on my anaconda set up. I don't get a rocket, but I get an app icon that flashes for a while and a beachball if I don't change focus back to the terminal. Qt5Agg is the backend both before and after This is definitely to do with the Framework build - if I use the non-framework build, and use Qt5Agg, the extra dock icon never shows up. The dock icon controls the visibility of the window that shows up if I call Reverting to 2.2.3 this doesn't happen. |
er, I meant matplotlib/lib/matplotlib/__init__.py Lines 876 to 880 in 09e9504
The bouncing does not start until you import I suspect the issues are in matplotlib/lib/matplotlib/pyplot.py Lines 2331 to 2339 in 09e9504
|
Just commenting all that out doesn't change the behaviour for me (and the if conditional is |
Same (correct) behaviour as above.
Exactly.
OK, I've played with this code a bit. The But note that this behaviour is still a bug, I think -- under 2.7, the icon didn't bounce. |
Hmmm: As per above, the |
Not surprisingly bisects to 56acb0f
|
The culprit looks to be: matplotlib/lib/matplotlib/pyplot.py Lines 214 to 215 in 09e9504
If I run this line I get the bouncing dock - so I guess |
#12207 removes the check that opens the framework if using a non-GUI backend. If you use a GUI backend, I guess this icon coming up upon import is expected behaviour (?)... |
I think there are actually two issues here,
|
I can confirm the same behavior on Python : 3.6.5 64bit [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] I had written a question on stackoverflow which is well described by this issue. |
OK, to clarify a few things: Using the conda framework build ( v2.2.3:If I run:
Similarly:
The terminal loses focus and the icon "bounces" if I use the conda framework build. Conclusion: the bouncing has always been there if you specify "macosx" and use the framework build. So @tacaswell's issue 1 above is not something we should consider fixing as a bug fix for 3.0.x. If someone wants to figure out this behaviour, they should feel welcome to do so. As @dstansby points out above the origin of this behaviour is in the v3.0.0The issue is that with the new changes, import pyplot calls @anntzer or @tacaswell will have to explain the logic here, but I think the idea is that if a backend has not been set, we should check to see if Matplotlib is supposed to be running in GUI. But it seems to be checking even if the backend has been set, and that is what is causing the problem here. I don't understand the new backend switching logic, but we either need to not call Assigning the folks who understand this logic better, but more than willing to help test changes... |
I'll explain the current design and why it is as it is. Before matplotlib 3.0, we shipped (i.e., Matplotlib wheels, conda packages, linux packages, etc.) a default matplotlibrc file with a Given the issues described above, for matplotlib 3.0, we changed the setup so that the default matplotlibrc does not include a If there is no How do we know whether "the backend requires a GUI framework that is incompatible with the currently running GUI framework (if any)"? Backends have been changed to additionally expose a However, it is clear that this comparison must occur during backend fallback. Therefore, moving the check down to Canvas or Manager instantiation time, as proposed by #12557, won't work, in the sense that backend fallback won't be able to detect some cases (namely, non-framework Pythons that don't have a Really, the main necessity of the check is to know whether, yes or not, the current Python build is a framework Python build or not. I'd hope this is something that can be done without triggering rocket bounces, but I don't know enough about OSX to tell. It is somewhat sad, however, that the "official" way to perform that check (checking some stuff in the sysconfig module) doesn't work because conda's "framework" build is not a real framework build but something that fakes it :/ ( |
An interesting point that may have not been noted before: On my
does not bounce the icon -- the icon appears, but it doesn't bounce. But it does appear and bounce under |
OK, but thats 2.3.3 behaviour. Lets try to stick w/ the changes in 3.0.0 for this issue, which is that the icon gets activated even when it should not. If you think the old 2.2.3 behaviour is also undesirable, maybe open a new issue? |
I was pointing it out mostly in case the different REPL v ipython behaviour was a hint about something! |
Thanks for the info @jklymak and @anntzer. So, given the backend check needs to be done for the fallback logic, this is what I've found out about the bouncing icon. It is caused by one of these two lines in Lines 2584 to 2585 in a43fd85
Removing one or both of those checks stops the icon bouncing, but doing so does not properly identify framework vs. non-framework builds (#12252). Both of those calls are from the old OSX Carbon framework, and they were both deprecated in OSX 10.9 (a while ago!). So, the answer might lie in replacing the calls to Alternatively the call to |
This looks to be partially resolved (should only affect people who intend to use the macosx backend?) pushing to next milestone as we want to get 3.0.1 out the door. |
Hi @tacaswell and @jklymak: I have managed to get master running here, and it does seems to solve the problems as stated: the icon only shows up for the macOSX backend. Curiously, and perhaps related to previous comments, it bounces from the standard REPL, but the icon appears without bouncing in ipython or jupyter. |
I wonder if this is somehow related to readline..... |
Indeed, perhaps it'll help to first call GetFrontProcess (https://developer.apple.com/documentation/applicationservices/1501050-getfrontprocess?language=objc) before doing all that manipulation, and restore it at the end? |
I'm going to close because I think this is as good as we are going to get for now. There is a PR for 3.1 (#12633) that might make life even better for mac backend users... |
I had this problem in matplotlib==3.0, upgrading to 3.1 solved my problem. |
3.4.2 bounce bounce bounce :/ |
@neilyoung please open a new issue with version info, and exactly how you installed Matplotlib and python. Thanks! |
Thanks for the response. Meanwhile I found a work around by |
How did you install python 3.9, and what does "installed globally" mean? |
Sorry for not being specific enough. 3.9 comes with brew, install globally means "sudo python3 -m pip install matplotlib==3.4.2" EDIT: 3.9 is default with macOS 11 |
I cannot reproduce with python3 3.9.1 from homebrew, neither by calling
import matplotlib.pyplot as plt nor via the REPL. I did not install globally, because that is not a good idea in general, so maybe that is the difference? Again, please open a new issue, and explicitly state what you did to install python and what you did to install matplotlib. Further state exactly what steps you took to get the bouncing doc. |
This is not my app :) I'm running a script in a "for" loop, which updates dots and lines and calls "plt.draw()". This script (not mine) is supposed to work on other OS. Again. I'm through with this. For me the pause works. Thanks. Don't worry |
Bug report
Bug summary
Rocket icon appears in dock (and bounces) when
matplotlib.pyplot
is imported after installing matplotlib 3.0. In previous versions, this didn't happen (and still doesn't withpython2
on the same machine)Code for reproduction
Actual outcome
Rocket icon appears in MacOS dock and bounces for a while.
Expected outcome
Nothing (no dock icon for previous versions).
Matplotlib version
Installed from pip.
I haven't seen any other complaints about this, so I suspect that there is something specific to my setup.
Perhaps related to this ipython issue (but this happens even from the plain python3 REPL.) I
The text was updated successfully, but these errors were encountered: