-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MatPlotLib not working with Ubuntu 18.04 and TkAgg (Plot window looks like a black square). #13988
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
if you do My guess is that somehow the tk event loop is not being run. |
No, same exact output. |
do other Tk apps (ex idle) work? |
Yes, I have an application embedding the some matplotlib plots into a frame, and the rest of the application works fine. Only the plotting doesn't work. |
does That you are embedding this in a bigger Tk application is a rather critical detail. If you are embedding, see https://matplotlib.org/gallery/user_interfaces/embedding_in_tk_sgskip.html . Does this work as expected from an (i)python prompt without your application? |
No it doesn't work. Fig.canvas.draw() doesn't work. Using pyplot to generate a gui doesn't work. |
It is very hard to debug from the amount of information here and without access to the system. What were the version numbers that you tried? I am not surprised that master branch did not work as it is python 3.6+ . Can you try downgrading Matplotlib versions until it works? We did recently change the way we bind to tk to make it possible for pypy to work. |
I just tried 3.0.3 and 1.5.3. Neither worked, same result with both. Edit: This was on Ubuntu 18.04 on the odroid c1+ |
Doesn't work with Ubuntu 16.04 on either Python 2.7 or Python 3.5 |
This suggests that it something in your local configuration. Do any of the other GUI backends work? |
I have similar problem on Ubuntu 18.04.3. I see gray plots. The problem happens frequently, but randomly. Interestingly, an opened gray plot fixes itself if I switch to a different Ubuntu desktop and back, or press "Show Applications" overlay. I'm using TkAgg backend with Matlotlib v 3.1.1. |
You just saved my life! lol thanks |
This is still an issue pyplot.show() does not work in fresh install of Ubuntu 18.04.3 LTS results in program hanging and never resolves or faults tested with several backends to the same results fault looks to be with matplotlib somewhere |
IDENTIFIED CAUSE |
I seriously doubt that simply adding a |
@evgenyneu did you ever resolve the issue? I just upgraded Ubuntu 16.04 to 18.04 and now my plots are temporarily hanging (freezing), showing a grey plot area similar to your image. It happens intermittently and sometimes it hangs for a longer time. Using matplotlib 3.1.2 (problem occurred with 3.1.1, but not prior to the upgrade to 18.04) and Python 3.6.8 in a virtual env. Problem happens in Sublime Text or VSC. |
To clarify, I'm running Ubuntu 18.04, Python 3.8.6, TkAgg backend (I checked), and Matplotlib 3.1.2 in my virtual environment. As I mentioned, I did not have this problem until I upgraded my system to 18.04 from 16.04. The python scripts run, but the plots, which have a 5 second pause (so that I can examine the output before the next plot is shown) hangsintermittently, showing sometimes a blank black screen or a grey screen before the plot is correctly shown. The duration varies, but if I wait long enough it unhangs and the script continues. Sometimes, just clicking on the second monitor area appears to cause the script to resume:
I also installed tk: $ sudo apt-get install python3-tk And have added the extra line below the import line, which I don't think is necessary (and it didn't seem to make a difference): import matplotlib |
Does anyone have answer for this? Matplotlib still hangs intermittently for me when I run a script with multiple calls to plot. The program can show 15 or more plots before it hangs (sometimes with a grey or black plot screen). If I do nothing it seems to remain in that condition indefinitely. But if I do other activities on the screen (e.g., type an email, search on the web, etc.), it will resume with the plot and continue with the python script. I have pip uninstalled and pip re-installed matplotlib and checked the backend as TkAgg. What else? |
For anyone that may be reading this, I discovered that hitting only the CTRL or shift keys on my keyboard causes matplotlib to resume plotting the figure until it hangs again. Also, I commented out |
plt.show(block=True) resolved this for me. Thanks. |
Hi, Are you now able to see the plots in a window by adding this line in your code? I've been facing the same issue and I'm trying to fix it. TIA. |
@SanmithraMudigonda I was never able to resolve this issue. Presently, I am using a different computer (different Nvidia graphics card), but still running Ubuntu 18.04. However, I'm running Python 3.6.9 and don't have this problem - even while running the exact codes! I cannot explain why it works on a different machine. My guess it probably has something to do with the driver used for the graphics. I hope you are able to resolve this. |
@Jarvine Thanks for the response. I am running Python 3.6.9 on Ubuntu 18.04 too, but on the Windows Susbystem for Linux. I am yet to figure out what works for me here. |
@SanmithraMudigonda Even if I run the same code on my Macbook pro, Python 3.6.8, I don't have this problem. The problem surfaced when I upgraded to 18.04 from 16.04. Initially, I was running tensorflow on my Ubuntu 16.04, which meant that I had installed Cuda and the nvidia driver manually, based on the tensorflow website recommendation. When switching to 18.04, I suspect that Ubuntu updated the driver to the default for my cards. I really believe it is a driver compatibility issue. Have you updated your driver? Are you using an nvidia graphics card? |
@SanmithraMudigonda Do you have an xserver installed? What do you get if you do @Jarvine I am very skeptical that it could be driver related, there is enough layers of abstraction between the graphics drivers and mpl that something very very strange would have to be happening for there to be a driver issue that only his us. I suspect in is far more likely to be interactions between tk, its event loop, and the desktop manager. |
It might be helpful for debugging if we supplied folks with a dummy program for some of the more popular backends so they can make sure their install is OK? I am too ignorant of the various backends to know what such a dummy program might be, but I think it'd help many users who also don't know how to write a little tK or Qt app. |
python -c "from PyQt5.QtWidgets import *; app = QApplication([]); win = QMainWindow(); win.show(); app.exec()" (or replace import with PySide2, if desired). |
For GTK:
|
@Jarvine I haven't explicitly updated any of my drivers while trying to make this work. My machine has a Intel Graphics card. @tacaswell I do not have an x server installed. You're right, the |
@QuLogic just as a side point, when giving this kind of command lines, I prefer putting double quotes around the outside string (assuming that there are indeed no problematic shell metacharacters in the string) because that makes them also work on Windows (cmd.exe only accepts double quotes, not single quotes). |
@SanmithraMudigonda If |
@SanmithraMudigonda See https://matplotlib.org/tutorials/introductory/usage.html?highlight=what%20backend#backends for details about backends. Given that you specified a non-interactive backend, not getting a window is the expected behavior (even if it is not the behavior you wanted!). You are having a different problem that the OP, if the link above does not help you can you please post at https://discourse.matplotlib.org/ ? |
@jklymak thank you, it does look like an issue with my |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
This issue is still troubling me, and none of the backends are working on my Ubuntu 18.04 system. |
Bug report
Bug summary
When using MatPlotLib with the TkAgg backend on Ubuntu 18.04, with either Python 2.7 or 3.5, plots are not displayed instead a window that is completely black is displayed.
Code for reproduction
Actual outcome
The window pops up, except no plot is displayed instead the plot window is just completely back.
Expected outcome
A simple chart of a line-graph going from 1 to 4 to 6. Works on Ubuntu 12, and windows, same versions of MatPlotLib
Matplotlib version
print(matplotlib.get_backend())
): 'TkAgg'The text was updated successfully, but these errors were encountered: