Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apps not popping up on macOS Big Sur 11.0.1

It is always risky to upgrade your operation system. It is likely you will encounter some compatibility issue. I took the risk to upgrade my macOS from Catalina to the newest Big Sur. After that, the display in the new OS looks pretty, but all my PyQt5 apps could not be launched in this new OS. The GUI window does not pop up as usual, and there is no error message showing in the terminal. I spent the whole day trying to figure out what makes this problem. I found the solution but in a weird way which I feel confused.

It turns out that the apps comes back to normal after I add the following three lines in the main script.

import matplotlib
import matplotlib.pyplot as plt

matplotlib.use('TkAgg')

It seems to me the new OS has some compatibility issue with Qt5Agg back-end. But the strange thing is that this solution also works for one of the Pyqt5 app, where I don't use matplotlib at all.

The Python version I used is 3.8.4, and the PyQt5 version I have is 5.15.1.

I hope somebody could explain to me what happen under the hood that makes this solution work. Also I hope this temporary solution can help somebody with the same problem.

like image 278
Canrong Qiu Avatar asked Nov 14 '20 11:11

Canrong Qiu


People also ask

Why can’t I download macOS Big Sur on my Mac?

Internet connectivity issues or Apple’s server issues could likely be a reason for this error as well. To fix this, you can start your Mac in safe mode by holding the Shift key while your system boots and then try to download/install macOS Big Sur again.

What's new in macOS Big Sur 11?

macOS Big Sur 11.0.1 enables you to test your iPad and iPhone apps through Xcode. Below are notes pertaining to running these apps on macOS Big Sur 11.0.1. For additional macOS 11 changes, see macOS Big Sur 11.0.1 Release Notes.

Why do my apps crash after updating to macOS Big Sur?

Some of the apps installed on your Mac may behave abnormally or crash upon launching after updating to macOS Big Sur. This is likely because the apps haven’t been updated to support the latest version of system software yet.

Why is my Mac running slow after the macOS Big Sur update?

This is a pretty common issue after every major macOS update, but there’s nothing to worry about in most cases. After successfully installing the update, if macOS Big Sur notified you with a message saying “Optimizing Your Mac: Performance and battery life may be affected until completed”, then it’s nothing out of the ordinary.


3 Answers

I can confirm that matplotlib.use('TkAgg') followed by matplotlib.use('Qt5Agg') makes things work for me, too. I whittled it down to this as also working:

# from matplotlib.backends import _tkagg
import _tkinter
import matplotlib.pyplot as plt
plt.figure()

So it's something about the compiled _tkinter module. Maybe the inputhook?

like image 145
Eric Avatar answered Oct 12 '22 10:10

Eric


I followed the solution here and downgraded to PyQt 5.13. This solved my issue and allowed my compiled apps to run on Big Sur.

pip install PyQt5==5.13
like image 44
user11030774 Avatar answered Sep 25 '22 13:09

user11030774


As @Eric said, just add the following on the very start of your code, before the PySide2 import:

import os
os.environ["QT_MAC_WANTS_LAYER"] = "1"

Then import PyQt5/PySide2.

like image 2
Martí Climent Avatar answered Oct 12 '22 10:10

Martí Climent