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

标签 python-3.x macos qt pyqt5

我正在尝试在我的 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

当我做“酿造 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

但我仍然有同样的问题。

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

最佳答案

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

关于python-3.x - QObject::moveToThread:当前线程(0x7fec075fd3a0)不是对象的线程(0x7fec07e67800)。无法移动到目标线程 (0x7fec075fd3a0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66663419/

相关文章:

python-3.x - python Datetime - 提取年份和月份

macos - 如何在 XQuartz 中使用 ImageMagick

macos - Safari 中有没有办法将新标签的焦点默认设置为搜索框?

python - 提取分配的变量名称

python-3.x - KeyError : ('count' , 'occurred at index 0')

python - 按行主要顺序填充二维矩阵

objective-c - 音频播放的准确(音乐级)计时

c++ - 如何自定义QSlider的凹槽

c++ - Windows 7 和 C++ : Cross compiling application for use on Raspberry Pi

Qt如何在光标位置将html插入到可编辑的QWebView中?