PyInstaller致命错误:找不到“ zmq.h”文件

时间:2020-05-26 11:28:11

标签: python macos pyinstaller

在运行pyinstaller的MacOS上,我得到以下跟踪:

35 INFO: PyInstaller: 3.6
35 INFO: Python: 3.7.7
41 INFO: Platform: Darwin-16.7.0-x86_64-i386-64bit
44 INFO: UPX is not available.

[...]

55950 INFO: Loading module hook "hook-zmq.py"...
/usr/local/lib/python3.7/site-packages/zmq/backend/cffi/__pycache__/_cffi_ext.c:216:10: fatal error: 'zmq.h' file not found
#include <zmq.h>
         ^
1 error generated.
57608 INFO: Loading module hook "hook-gevent.py"...
57732 INFO: Determining a mapping of distributions to packages...
83010 WARNING: Unable to find package for requirement greenlet from package gevent.

[...]

83742 WARNING: library user32 required via ctypes not found
83832 WARNING: library setupapi required via ctypes not found
83833 WARNING: library Advapi32 required via ctypes not found

[...]

125669 INFO: Building EXE from EXE-00.toc completed successfully.

这不会阻止构建过程,但是当我运行输出程序时,我会得到

Segmentation fault: 11

还有其他人遇到过这个问题吗?

1 个答案:

答案 0 :(得分:0)

我发现在PyInstaller生成的警告文件中进行搜索非常有用

在命令输出中有一行

85263 INFO: Warnings written to /path/to/warn-file.txt

如果我搜索zmq,则第一个警告是顶级导入

missing module named multiprocessing.Process - imported by multiprocessing (top-level), zmq.ssh.tunnel (top-level)

这给了我2条提示:

  • 多处理涉及仅在该文件中显示的许多警告
  • 在文件中搜索大量与 PyQt5 相关的警告,该警告已导入到我的应用程序中

我搜索了多处理和pyqt导入,并删除了两个未使用的导入:

from PyQt5.uic import compileUiDir
from multiprocessing import Pool as ThreadPool

这并不能消除奇怪的zmq.h缺少标头致命错误,但是可以使应用程序在构建后正确运行。

在这里分享我的解决方案,也许对其他人有用...