macOS Big Sur 11.0.1 上未弹出应用程序

Apps not popping up on macOS Big Sur 11.0.1(macOS Big Sur 11.0.1 上未弹出应用程序)

本文介绍了macOS Big Sur 11.0.1 上未弹出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级操作系统总是有风险的.您可能会遇到一些兼容性问题.我冒险将我的 macOS 从 Catalina 升级到最新的 Big Sur.在那之后,新操作系统中的显示看起来很漂亮,但是我所有的 PyQt5 应用程序都无法在这个新操作系统中启动.GUI 窗口没有像往常一样弹出,并且终端中没有显示错误消息.我花了一整天的时间试图弄清楚是什么导致了这个问题.我找到了解决方案,但以一种奇怪的方式让我感到困惑.

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')

在我看来,新操作系统与 Qt5Agg 后端存在一些兼容性问题.但奇怪的是,这个解决方案也适用于其中一个 Pyqt5 应用程序,我根本不使用 matplotlib.

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.

我使用的Python版本是3.8.4,我的PyQt5版本是5.15.1.

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.

推荐答案

回复 PyQt 邮件列表指出设置这个 env var 有效:

A reply to the PyQt mailing list pointed out that setting this env var works:

QT_MAC_WANTS_LAYER=1

通过 是否有任何关于 PyQt 库在 Mac OS Big Sur 中不起作用的解决方案? 和 https://forums.macrumors.com/threads/pyqt5-and-big-sur.2260773/?post=29243620#post-29243620

这篇关于macOS Big Sur 11.0.1 上未弹出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:macOS Big Sur 11.0.1 上未弹出应用程序

基础教程推荐