Open ocroquette opened 4 years ago
This happens because we are patching QApplication
in order to allow people to run Qt apps multiple times in our consoles:
The problem is that I am working with a 3rd party component that uses also Qt, but the files used are not compatible with the ones provided on the Python side
I really don't get this part. How is your component supposed to work if it doesn't import the PyQt libraries present in the Python environment you're using?
@impact27, I think @ocroquette expectations are correct in the sense that if "Activate support" is off, we should not patch QApplication
on our side. Otherwise, use cases like his are not feasible in Spyder.
What do you think?
The problem is that I am working with a 3rd party component that uses also Qt, but the files used are not compatible with the ones provided on the Python side
I really don't get this part. How is your component supposed to work if it doesn't import the PyQt libraries present in the Python environment you're using?
Thanks for the quick feedback.
The 3rd party component is not using PyQt. Actually it doesn't have anything to do with Python. I am loading it with ctypes.
@impact27, I think @ocroquette expectations are correct in the sense that if "Activate support" is off, we should not patch
QApplication
on our side. Otherwise, use cases like his are not feasible in Spyder.What do you think?
Sounds reasonable, but this is not related to matplotlib support, so either we disable the patching entirely, or we add another option.
Ok, what name do you have in mind for another option? And where should we put it?
Is it possible to avoid an additional option and instead detecting at runtime automatically if the patch is necessary ? For instance, using an import hook like in sys.path_hooks (https://docs.python.org/3/reference/import.html)
Hi, since last year I was just modifying spydercustomize.py to make the patch (https://github.com/spyder-ide/spyder-kernels/blob/46e2c1b583f7cd8190795f8d189be58da7f6667e/spyder_kernels/customize/spydercustomize.py#L147-L183) optional and not active by default for our internal Python distribution. It worked fine, but while preparing a new version of the distribution, I realized that the PyQt modules were loaded again unconditionally.
Something else is loading 'matplotlib.backends.qt_editor', 'matplotlib.backends.qt_compat', 'matplotlib.backends.qt_editor._formlayout', 'matplotlib.backends.qt_editor.figureoptions', 'matplotlib.backends.qt_editor._formsubplottool', 'matplotlib.backends.backend_qt5', 'matplotlib.backends.backend_qt5agg'.
The problem is I don't know what is causing them to be loaded. Is there any way to find out?
It would be nice to find a solution. I am starting to think that Spyder is not an option anymore to develop PySide2 applications :(
Hi @ocroquette maybe the loading is related with the logic to detect if matplotlib
is available and to initialize the backend value here?: https://github.com/spyder-ide/spyder-kernels/blob/46e2c1b583f7cd8190795f8d189be58da7f6667e/spyder_kernels/console/start.py#L146-L217
Thanks for the quick feedback. I doubt it, since this code looks very old. I actually downgraded Spyder to a 4.x version using PIP, and the Qt packages were still loaded. So I have the impression that this is caused by a dependency of Spyder, rather than Spyder itself. Still, I will have a closer look at start.py. Cheers, Olivier
I think I found the problem: Matplotlib added a mechanism to automatically set the "right" backend when imported, which in turn imports PyQt5. I'll try to fix that in the next version of spyder-kernels (see https://github.com/spyder-ide/spyder-kernels/pull/319).
Great, thank you for the feedback. Out of curiosity, do you happen to have a link to the change in matplotlib ?
No, I haven't, sorry.
Issue Report Checklist
conda update spyder
(orpip
, if not using Anaconda)jupyter qtconsole
(if console-related)spyder --reset
Problem Description
When working in an IPython console, the Qt libraries are loaded even when the matplotlib support is disabled.
What steps reproduce the problem?
What is the expected output? What do you see instead?
Expected output: nothing
Actual output:
The problem is that I am working with a 3rd party component that uses also Qt, but the files used are not compatible with the ones provided on the Python side. Since Spyder already loaded them, the 3rd party component fails to work at all. I am force to start it in an external interpreter, but then I loose many features of the IDE (debugger, variable manager...).
Modifying the "Backend" setting (for instance, setting it to "Automatic") doesn't help.
Versions
I use Spyder 4.1.4 installed with pip.
4.0.1 is NOT impacted. If I install specifically this version, I can work with the 3rd party component. This is currently my workaround.
Dependencies
I cannot check at the moment, but I will if it helps