QObject::moveToThread: 当前线程 (0x7fec075fd3a0) 不是对象的线程 (0x7fec07e67800)。无法移动到目标线程 (0x7fec075fd3a0)。

3
我将尝试在我的 MAC OS Catalina 上使用 PyInstaller 编译我的 Python 3.9 脚本: MAC OS CATALINA 10.15.6 Python 3.9 Pyinstaller 4.2
我的脚本使用 PyQt5 制作了一个 GUI。如果我运行“pip freeze”命令,我会看到以下内容:
PyQt5==5.15.4
PyQt5-Qt5==5.15.2
PyQt5-sip==12.8.1
PyQt6==6.0.3
PyQt6-sip==13.0.1

当我执行“brew list”命令时,会得到以下结果:

assimp
glib
libpng
pcre2
readline
zstd
dbus    
icu4c
libproxy
pkg-config
sip
double-conversion
jasper
libtiff
pyinstaller
sqlite
freetype
jpeg
mpdecimal
pyqt
tcl-tk
gdbm
libb2
openssl@1.1
python@3.9
webp
gettext
libffi
pcre
qt
xz

一旦执行下面这行代码:

app = QtWidgets.QApplication(sys.argv)

我会尽力进行翻译,请问需要将内容翻译成哪种语言呢?
objc[32852]: Class QMacAutoReleasePoolTracker is implemented in both /usr/local/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1221c0198) and /Users/alisa/Dropbox/cff/Python/PhoneBotV3/dist/PhoneBot.app/Contents/MacOS/QtCore (0x1312c7198). One of the two will be used. Which one is undefined.
objc[32852]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /usr/local/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1221c0210) and /Users/alisa/Dropbox/cff/Python/PhoneBotV3/dist/PhoneBot.app/Contents/MacOS/QtCore (0x1312c7210). One of the two will be used. Which one is undefined.
objc[32852]: Class KeyValueObserver is implemented in both /usr/local/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1221c0238) and /Users/alisa/Dropbox/cff/Python/PhoneBotV3/dist/PhoneBot.app/Contents/MacOS/QtCore (0x1312c7238). One of the two will be used. Which one is undefined.
objc[32852]: Class RunLoopModeTracker is implemented in both /usr/local/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1221c0288) and /Users/alisa/Dropbox/cff/Python/PhoneBotV3/dist/PhoneBot.app/Contents/MacOS/QtCore (0x1312c7288). One of the two will be used. Which one is undefined.
objc[32852]: Class QCocoaPageLayoutDelegate is implemented in both /usr/local/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x12f315540) and /Users/alisa/Dropbox/cff/Python/PhoneBotV3/dist/PhoneBot.app/Contents/MacOS/QtPrintSupport (0x130066540). One of the two will be used. Which one is undefined.
objc[32852]: Class QCocoaPrintPanelDelegate is implemented in both /usr/local/lib/python3.9/site-packages/PyQt5/Qt5/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x12f3155b8) and /Users/alisa/Dropbox/cff/Python/PhoneBotV3/dist/PhoneBot.app/Contents/MacOS/QtPrintSupport (0x1300665b8). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7fec075fd3a0) is not the object's thread (0x7fec07e67800).
Cannot move to target thread (0x7fec075fd3a0)

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: cocoa, minimal, offscreen, webgl.

经过调查,我认为这是QT安装的问题。因此,我卸载了Qt和pyqt:
brew uninstall qt 
brew uninstall pyqt 
python3 -m pip uninstall pyqt5

然后重新安装所有相关内容:

brew install qt 
brew install pyqt 
python3 -m pip install pyqt5

但我仍然有同样的问题。

请问有人知道如何解决这个问题吗?


我在这里发布了我的解决方案:stackoverflow.com/a/72863910/3844056。你正在使用brew,而我正在使用anaconda3,但解决方案可能相同,以删除冲突的Qt版本。你的应用程序是否在venv中工作(与其他python版本/库隔离)?关于这个Qt版本/Users/alisa/Dropbox/cff/Python/PhoneBotV3/dist/PhoneBot.app/Contents/MacOS/QtCore发生了什么? - ruoho ruotsi
1个回答

1

只需安装opencv-python==4.1.0.25pyqt5==5.9.2


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接