-
Notifications
You must be signed in to change notification settings - Fork 297
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
%matplotlib QT5 doesn't work #8322
Comments
v2021.10.1001413611
, the following cells can not being executedv2021.10.1001409655
, the following cells can not being executed
Thanks for filing this issue, & I"m sorry yo'ure running into this.
Please could you
|
I will try to contribute with the information, I asked the original question at https://stackoverflow.com/questions/70056478/vscode-python-interactive-window-freezes-when-using-matplotlib First I can confirm that when not running %matplotlib (or even running %matplotlib inline) all works as expected. It is only when I have the external window that I see the problem. I've installed the code-insider edition and the python (including the jupyter) extension version Jupyter v2021.11.1001498571. Then I
I have attached the debug output to this message. Thanks for investigating the issue, |
@faultdiagnosistoolbox Looks like you have failed to attach the logs correctly. Please could you re-attach them
|
Oh, ok, I have not tried this. |
Tried, still unable to repro. I must be missing something This is the code I"m using %matplotlib
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
plt.plot(x, np.cos(x))
plt.show() & this is the output I get in VS Code When running the same code in Jupyter i the the output @faultdiagnosistoolbox @gonghenghai
More info here https://matplotlib.org/stable/users/explain/interactive.html?highlight=vscode#jupyter-notebooks-jupyterlab & https://matplotlib.org/stable/users/explain/backends.html?highlight=ipympl |
OK, strange. I have tried on 4 machines. It fails identically on two Macs (iMac, Macbook Pro) and my Ubuntu 20.04 Linux laptop. On my office Linux, also Ubuntu 20.04, workstation I can't reproduce. I thought I attached the debug log. I have copy-pasted it below, hope that is the correct way. Erik
|
@faultdiagnosistoolbox Yes, I don't expect that to work, Please try |
OK, that is unfortunate but it has worked before (and is also working now when I downgrade the Jupyter extension version)? In any case, thanks for investigating the issue. Unfortunately this (regrettably) makes me have to chose another tool than VSCode since the widget backend is not what I'm looking for (it is working though). |
What version have you tried, I tried this at my end and the plot didn't work (see here #8322 (comment)). |
I'm using VSCode version 1.62.3 and Jupyter extension v2021.9.1101343141. Everything else is up-to-date as far as I can tell. Then I can run %matplotlib and interactively run commands, produce plots, etc. Currently I'm sitting on a Mac, but I have the exact same experience on a Linux (Ubuntu 20.04) laptop. I've not had the chance to try on a Windows machine. Edit: I saw now that you asked for version of matplotlib earlier in the thread. I'm currently on 3.5.0 (running python 3.9). |
We might want to consider reverting this change and try it out: |
Going to try this today to see if I can get |
This works fine for me. See GIF: I got this working by
|
So if it's not working, it may be a qt5/matlplotlib issue. |
Verification steps:
|
@faultdiagnosistoolbox it looks like you're not using conda. The set of packages installed likely has a big impact on this. Running other code after the plot works fine for me using conda, but not with a venv. I recommend using the yml file I included above to create an environment where this works (or maybe use it to compare against what's in your venv). |
It is true, I don't normally use conda. Do I understand correctly that you get the same behavior as me in venv but it works in a conda environment? In my example above I created a minimal venv with only the required packages (all latest versions) to excite the problem. I will try to create a virtual environment based on the yml-file you created to see if there are any changes in behavior. |
For me if I create a virtual env from scratch, the creation of the plot hangs the kernel forever (so not exact same results). |
I can reproduce the steps too. I note that also typing any character in the interactive command line has the same "unblocking" effect on previous cells. This is on native Ubuntu 20.04. @rchiodo with regard to your question in the other thread about my use case -- my work is dependent on a library (MNE-Python) which requires the Qt backend for interactive plotting of large electrophys datasets. This setup allows me to plot my own matplotlib figures in the same environment with minimal friction, use the full screen space for large composite plots etc. My hard requirement is that I can use the MNE data viewer, which is unfortunately tied to Qt for now. My feature preference is plotting in separate windows. At present I'm using an old version of the Jupyter extension (v2021.10.1001393861) which works fine with qt magics. I can continue to work with this setup for the time being. |
More investigation notes: Running this code will also make it work (with or without restarting the kernel)
So it has something to do with us activating our widget manager. |
I can confirm that activating the widget manager made it work better also for me. First I thought it worked as desired, but the problems re-occurred after a few plotting commands. I did
Then iterating 3 (or other sinple 1+1 commands) makes it freeze for me, usually the second time but it varies. |
I did anything, and it doesn't work, so I have no choice but to install an old version (September version - 1.61.2). Thanks @faultdiagnosistoolbox and @gonghenghai, for bringing up the issue and I hope the vscode-jupyter team will consider fixing this issue soon as this feature is very important to everyone who works analyzing data (data scientist, data analyst, data engineer) . |
v2021.10.1001409655
, the following cells can not being executed
I've submitted what I think is a fix. Hopefully it will come out in our 'prerelease/insiders' build tonight (in about 7 hours from when I write this comment) If anybody can try it, that'd be great. |
thanks @rchiodo |
Yep that's the one. Glad to hear it's working. |
Closing as fixed. Verification steps:
|
I can confirm that it also works for me. Thank you! |
Yes, it is working !! |
As others have said, this is working now. Thank you very much for fixing this. |
It also works for me. Thank you very much, this is of huge help! |
@faultdiagnosistoolbox @bermeom @Groberts93 @karahanyilmazer @pgA3D
Thank you, and really appreciate your help in this space. |
Environment data
Expected behaviour
Execute the cells
Actual behaviour
Just waiting
The text was updated successfully, but these errors were encountered: