pyinstaller打包问题

1.打包出现warning,执行提示dll找不到

45684 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\message.pyd
45785 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\_device.pyd
45884 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\utils.pyd
45983 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\socket.pyd
46082 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\_poll.pyd
46190 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\context.pyd
46302 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\error.pyd
46404 WARNING: lib not found: libzmq.pyd dependency of C:\Program Files\Anaconda2\lib\site-packages\zmq\backend\cython\_version.pyd
ImportError: DLL load failed:

原因是zmq.backend.select使用__import__动态加载,编译时对pyinstaller来说是无法引入的,需要手动指定hidden导入

解决办法:

pyinstaller  --noconfirm --log-level=WARN ^
             --hidden-import=zmq.backend ^
             --hidden-import=zmq.backend.cython ^
             --hidden-import=zmq.backend.cffi ^
             --hidden-import=zmq.error  ^
             --hidden-import=zmq.sugar ^
             --hidden-import=zmq.utils ^
             --paths="C:\Program Files\Anaconda2\lib\site-packages\zmq" ^
             zmqtest.py

你可能感兴趣的:(python)