简体   繁体   English

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

[英]PyInstaller fatal error: 'zmq.h' file not found

On MacOS running pyinstaller I get the following trace:在运行 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.

This does not block the build process, but when I run the output program I get这不会阻止构建过程,但是当我运行 output 程序时,我得到

Segmentation fault: 11

Anyone else experienced this issue?其他人遇到过这个问题吗?

I found very useful to search in the warnings file generated by PyInstaller我发现在PyInstaller 生成的警告文件中搜索非常有用

In the command output there's a line在命令 output 有一行

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

If I search for zmq the first warning is a top-level import如果我搜索 zmq,第一个警告是顶级导入

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

That gave me 2 hints:这给了我2个提示:

  • multiprocessing was involved in a lot of warnings shown only in that file多处理涉及许多仅在该文件中显示的警告
  • searching through the file a lot of warnings where related to PyQt5 which is imported in my application在文件中搜索很多与在我的应用程序中导入的PyQt5相关的警告

I searched for multiprocessing and pyqt imports and removed two unused imports:我搜索了 multiprocessing 和 pyqt 导入并删除了两个未使用的导入:

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

This doesn't remove that strange zmq.h missing header fatal error but it makes the application run correctly after the build.这并没有消除奇怪zmq.h缺少 header 致命错误,但它使应用程序在构建后正确运行。

Sharing my solution here, maybe it can be useful for others...在这里分享我的解决方案,也许它对其他人有用......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM