Mac Big Sur config to open windows in Terminal with PyQt5 or PySide2?

I updated my mac’s OS from Catalina to Big Sur a few days ago. Since then, scripts that open a window with PyQt5 or PySide2 work as expected when started with IDLE’s File, Open Module command. But if I run them with a Terminal command or in Visual Studio Code, they start OK with no indications of trouble but no window ever opens. The Python icon appears in the Dock and Activity Monitor says a Python process is running and using 99% of a CPU. I have to Force Quit it to stop it. This happens even with the simplest scripts in the “basic” source code folder with the Learning PyQt book. I don’t know a lot about Python configuration. I probably didn’t get everything setup properly for the new OS. I’d appreciate suggestions.

macOS About shows: Version 11.0.1
python3 -V returns Python 3.9.0
(On mac, Python commands without a suffix name version 2 programs which comes with macOS. Version 3 commands have a “3” suffix.)
pip3 -V returns: pip 20.2.4
pip3 list returns:
PyQt5 5.15.1
PySide2 5.15.1
In a Terminal window, %echo $PATH returns:
/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet

1 Like

Hey, I haven’t upgraded my Mac laptops yet (will give it a go with one at the weekend) but I’ve read elsewhere that downgrading PyQt5 to v5.13 helps fix the issue – I wonder if it’s just the act of re-installing that helps though to be honest, have had to do that on previous Mac upgrades.

So either

pip3 install --force-reinstall pyqt5

or…

pip3 install pyqt5==5.13

I did pip3 install pyqt5==5.13. Same problem.

Before that, I uninstalled/removed everything related to Python 3, restarted the mac and reinstalled Python 3.9.0 and PySide2. Same problem.

A script that opens a window with Tkinter works OK when started with a Terminal command, Visual Studio Code or IDLE3.

I’d sure appreciate hearing whether other Big Sur users are or are not having the same problem.

Here’s the PySide2 script I’ve been experimenting with:

from PySide2.QtWidgets import QApplication, QWidget
import sys
app = QApplication(sys.argv)
window = QWidget()
window.show()
app.exec_()

and here’s the Tkinter script:

from tkinter import Label
widget = Label(None, text=‘Hello GUI world!’)
widget.pack()
widget.mainloop()

Not that this helps much, however I two conda environments, which according to conda both contain pyqt-5.9.2

However when I run the following script:

import inspect
from PyQt5 import Qt

vers = ['%s = %s' % (k,v) for k,v in vars(Qt).items() if k.lower().find('version') >= 0 and not inspect.isbuiltin(v)]
print('\n'.join(sorted(vers)))

I discover one environment, the one that works, contains pyqt5 5.9.2 (PYQT_VERSION_STR = 5.9.2)
and the environment that doesn’t work contains pyqt5 5.15.1 (PYQT_VERSION_STR = 5.15.1)

Where “works” = generates a window containing widgets.

Thanks for the suggestion. When I try to install versions earlier than 5.13, Pip says:
% pip install PyQt5==5.9
Collecting PyQt5==5.9
Using cached PyQt5-5.9-5.9.1-cp35.cp36.cp37-abi3-macosx_10_6_intel.whl (82.2 MB)
ERROR: Could not find a version that satisfies the requirement sip<4.20,>=4.19.3 (from PyQt5==5.9) (from versions: 5.0.0, 5.0.1, 5.1.0, 5.1.1, 5.1.2, 5.2.0, 5.3.0, 5.4.0)
ERROR: No matching distribution found for sip<4.20,>=4.19.3 (from PyQt5==5.9)

I don’t know enough about Python to understand the problem. I was able to install 5.13 and 5.14. They work the same as 5.15.

Martin is likely to have a better handle on the changes made 5.13 -> 5.15 and one would hope that riverbank might have some release notes.

For my part I’ve discovered that 9.5.2 is a pure Anaconda installation, however the environment that didn’t work for me containing pyqt5 5.15.1 was a result of me piping on top of a previous Anaconda installation.

When I pip3 uninstalled pyqt5 and then used conda install pyqt5 again things went back to normal and started working.