python-3.x - 使用 PyInstaller 在 MacOSX 下 PyQt5 和 Cocoa 之间的问题
问题描述
我安装了 OSX Mavericks 以确保我正在开发的应用程序可以在这个系统上运行。我使用 PyInstaller 进行编译(我使用 PYInstaller 的构建脚本运行时没有错误)。
问题是,当我双击可执行文件时,出现此错误:
Last login: Wed Jan 16 22:56:18 on ttys004
Mac-Pro-de-angelo:~ angelo$ /Users/angelo/miniconda3/envs/apsc/apsc_1_0_0_onefile_mac_osx/apsc ; exit;
objc[5125]: Class RunLoopModeTracker is implemented in both /var/folders/t0/s6_p_gn15798z_8m8w5f6vjm0000gn/T/_MEIWgQ7yV/libQt5Core.5.dylib and /Users/angelo/miniconda3/envs/apsc/lib/libQt5Core.5.6.2.dylib. One of the two will be used. Which one is undefined.
objc[5125]: Class NotificationReceiver is implemented in both /var/folders/t0/s6_p_gn15798z_8m8w5f6vjm0000gn/T/_MEIWgQ7yV/libQt5Widgets.5.dylib and /Users/angelo/miniconda3/envs/apsc/lib/libQt5Widgets.5.6.2.dylib. One of the two will be used. Which one is undefined.
objc[5125]: Class QCocoaPageLayoutDelegate is implemented in both /var/folders/t0/s6_p_gn15798z_8m8w5f6vjm0000gn/T/_MEIWgQ7yV/libQt5PrintSupport.5.dylib and /Users/angelo/miniconda3/envs/apsc/lib/libQt5PrintSupport.5.6.2.dylib. One of the two will be used. Which one is undefined.
objc[5125]: Class QCocoaPrintPanelDelegate is implemented in both /var/folders/t0/s6_p_gn15798z_8m8w5f6vjm0000gn/T/_MEIWgQ7yV/libQt5PrintSupport.5.dylib and /Users/angelo/miniconda3/envs/apsc/lib/libQt5PrintSupport.5.6.2.dylib. One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7f9362f5b620) is not the object's thread (0x7f93640b2370).
Cannot move to target thread (0x7f9362f5b620)
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.
This application failed to start because it could not find or load the Qt platform plugin "cocoa"
in "".
Available platform plugins are: cocoa, minimal, offscreen.
Reinstalling the application may fix this problem.
Abort trap: 6
logout
[Opération terminée]
如果我参考这篇文章:
pyinstaller + pyqt5:找不到或加载“可可”
我遇到了同样的问题,但建议的解决方案不适用于我家。
这就是我的 PYInstaller 脚本的运行方式:
/Users/angelo/miniconda3/envs/apsc/bin/pyinstaller --clean --windowed --onefile --runtime-tmpdir /var/folders/t0/s6_p_gn15798z_8m8w5f6vjm0000gn/T --icon=logo_apsc_256x256.icns --distpath apsc_1_0_0_onefile_mac_osx --name apsc apsc_gui.py
为了准确起见,我的软件在直接从 Python 启动时在 MacOSX 下运行良好。
你能帮我找到解决办法吗?
这些是我的规格:
MacOSX 10.9.5 Python 3.4.5、qt-5.6.2、sip-4.18 和 pyqt-5.6.0 在 Miniconda3-3.8.3 下
... 后 ...
我真的很想解决这个问题,已经好几天了……我做不到。
它已经发展了一点,但我仍然有错误,在使用 PyInstaller 编译后,我仍然无法在 MacOSX 下启动我的软件(生成的应用程序),
这就是我所做的:
libpython3.6m.dylib 和 libpython3.6.dylib 之间的符号链接(后者在 miniconda3 中创建的环境的 bin 目录中不存在):
ln -s /Users/angelo/miniconda3/envs/test/lib/libpython3.6m.dylib /Users/angelo/miniconda3/envs/test/lib/libpython3.6.dylib
然后我下了订单:
export DYLD_PRINT_RPATHS=1
应该注意的是,我发现自己遇到了错误:
21966 ERROR: Can not find path ./libtbb.dylib (needed by /Users/angelo/miniconda3/envs/test/lib/libmkl_tbb_thread.dylib)
结果稍微好一点,但我总是发现自己有错误:
objc[2619]: Class RunLoopModeTracker is implemented in both /private/var/folders/t0/s6_p_gn15798z_8m8w5f6vjm0000gn/T/_MEIqjVaY5/libQt5Core.5.dylib and /Users/angelo/miniconda3/envs/test/lib/libQt5Core.5.6.2.dylib. One of the two will be used. Which one is undefined.
objc[2619]: Class NotificationReceiver is implemented in both /private/var/folders/t0/s6_p_gn15798z_8m8w5f6vjm0000gn/T/_MEIqjVaY5/libQt5Widgets.5.dylib and /Users/angelo/miniconda3/envs/test/lib/libQt5Widgets.5.6.2.dylib. One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7ff483848540) is not the object's thread (0x7ff48385ab60).
Cannot move to target thread (0x7ff483848540)
...我无法摆脱。
如果有人可以帮助我,我会很高兴,
请帮帮我。
解决方案
推荐阅读
- oracle - MS Access + Oracle Pass-Through SQL 与 DBLink 到另一个数据库
- spacy - python -m spacy.en.download 连接被拒绝 URLError
- c# - 处理不完整或出错的远程注销
- python - 仅当该列表中的字母已形成时才检查参数
- node.js - Docker 运行 wordpress + mysql + gulp(节点)
- ruby-on-rails - Rails:通过比较两个模型进行过滤
- firebase - 我们可以从控制台查看消息吗?
- bash - Bash 嵌套私有函数
- python - TensorFlow Keras 错误:预期 flatten_input 具有形状
- ios - 具有许多(100 多个项目)的表的静态表与动态原型