python 2.7 - pyinsataller misses libaries when building programms using pyzmq -


i try use pyinstaller build executable of worker client. client uses zmq communicate server. unfortunatelly pyinstaller seems miss libaries on build when zmq present. here minimalized example on win7 with

anaconda 2 (python 2.7.13)  zmq 16.0.2  pyinstaller 3.3.dev0 

pyinstaller installed using pip , working python files not using zmq. [update] updated pyinstaller according 9dogs comment, see info section. latest version additional warning every time call pyinstaller

c:\zmqtest>pyinstaller -v 16 warning: internal error: pywin32 import introduced 3.3.dev0+ga43a5d23 

content of zmqtest.py file:

import zmq port = "5551" context = zmq.context() client  = context.socket(zmq.req) client.setsockopt(zmq.constants.linger, 1) print 'connecting...' client.connect ("tcp://localhost:%s" % port) msgdict={} msgdict['foo']='bar' print 'send message...' client.send_json(msgdict) print 'recive message...' msgdict = client.recv_json() 

pyinstaller output:

   c:\zmqtest>pyinstaller zmqtest.py 36 warning: internal error: pywin32 import introduced 459 info: pyinstaller: 3.3.dev0+ga43a5d23 459 info: python: 2.7.13 459 info: platform: windows-7-6.1.7601-sp1 461 info: wrote c:\zmqtest\zmqtest.spec 463 info: upx not available. 466 info: extending pythonpath paths ['c:\\zmqtest', 'c:\\zmqtest'] 466 info: checking analysis 466 info: building analysis because out00-analysis.toc non existent 466 info: initializing module dependency graph... 473 info: initializing module graph hooks... 612 info: running analysis out00-analysis.toc 625 info: adding microsoft.vc90.crt dependent assemblies of final executable   required c:\program files\anaconda2\python.exe 838 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest 842 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_acd0e4ffe1daef0a.manifest 845 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_acd19a1fe1da248a.manifest 848 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.5054_none_acd24273e1d99eb3.manifest 851 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_acd388d7e1d8689f.manifest 1052 info: searching assembly amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none ... 1052 info: found manifest c:\windows\winsxs\manifests\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_08e61857a83bc251.manifest 1055 info: searching file msvcr90.dll 1055 info: found file c:\windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_08e61857a83bc251\msvcr90.dll 1056 info: searching file msvcp90.dll 1056 info: found file c:\windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_08e61857a83bc251\msvcp90.dll 1056 info: searching file msvcm90.dll 1056 info: found file c:\windows\winsxs\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_08e61857a83bc251\msvcm90.dll 1282 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_3da38fdebd0e6822.manifest 1285 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_acd0e4ffe1daef0a.manifest 1286 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_acd19a1fe1da248a.manifest 1288 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.5054_none_acd24273e1d99eb3.manifest 1289 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_acd388d7e1d8689f.manifest 1291 info: adding redirect microsoft.vc90.crt version (9, 0, 21022, 8) -> (9, 0, 30729, 6161) 1411 info: caching module hooks... 1417 info: analyzing c:\zmqtest\zmqtest.py 5973 info: processing pre-safe import module hook   _xmlplus 7472 info: processing pre-find module path hook   distutils 9082 info: processing pre-find module path hook   site 9085 info: site: retargeting fake-dir 'c:\\program files\\anaconda2\\lib\\site-packages\\pyinstaller\\fake-modules' 9125 info: processing pre-safe import module hook   win32com 10780 info: loading module hooks... 10782 info: loading module hook "hook-distutils.py"... 10783 info: loading module hook "hook-sysconfig.py"... 10786 info: loading module hook "hook-xml.py"... 10947 info: loading module hook "hook-zmq.py"... 14245 info: excluding import 'zmq.libzmq' 14246 info:   removing import of zmq.libzmq module zmq 14246 info: loading module hook "hook-pycparser.py"... 14499 info: loading module hook "hook-httplib.py"... 14502 info: loading module hook "hook-pkg_resources.py"... 15667 info: loading module hook "hook-gevent.monkey.py"... 18127 info: loading module hook "hook-pywintypes.py"... 18618 info: loading module hook "hook-setuptools.py"... 25410 info: loading module hook "hook-encodings.py"... 26375 info: loading module hook "hook-numpy.core.py"... 26513 info: mkl libraries found when importing numpy. adding mkl binaries 26516 info: loading module hook "hook-win32com.py"... 26696 info: loading module hook "hook-pythoncom.py"... 27161 info: loading module hook "hook-pydoc.py"... 27166 info: excluding import 'tkinter' 27167 info:   removing import of tkinter module pydoc 27168 info: loading module hook "hook-_tkinter.py"... 27345 info: checking tree 27347 info: building tree because out00-tree.toc non existent 27347 info: building tree out00-tree.toc 27599 info: checking tree 27599 info: building tree because out01-tree.toc non existent 27599 info: building tree out01-tree.toc 28049 info: checking tree 28049 info: building tree because out02-tree.toc non existent 28049 info: building tree out02-tree.toc 28055 info: looking ctypes dlls 28120 info: analyzing run-time hooks ... 28125 info: including run-time hook 'pyi_rth_multiprocessing.py' 28134 info: including run-time hook 'pyi_rth_pkgres.py' 28141 info: including run-time hook 'pyi_rth_win32comgenpy.py' 28161 info: looking dynamic libraries 44992 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_a551ff35e6a96bed.manifest 44996 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.5054_none_a5535ca9e6a81b96.manifest 45000 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_a554a30de6a6e582.manifest 45223 info: searching assembly amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none ... 45223 info: found manifest c:\windows\winsxs\manifests\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_044aad0bab1eb146.manifest 45226 info: searching file mfc90.dll 45226 info: found file c:\windows\winsxs\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_044aad0bab1eb146\mfc90.dll 45226 info: searching file mfc90u.dll 45226 info: found file c:\windows\winsxs\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_044aad0bab1eb146\mfc90u.dll 45227 info: searching file mfcm90.dll 45227 info: found file c:\windows\winsxs\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_044aad0bab1eb146\mfcm90.dll 45227 info: searching file mfcm90u.dll 45227 info: found file c:\windows\winsxs\amd64_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_044aad0bab1eb146\mfcm90u.dll 45434 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_a551ff35e6a96bed.manifest 45437 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.5054_none_a5535ca9e6a81b96.manifest 45438 info: found c:\windows\winsxs\manifests\amd64_policy.9.0.microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.6161_none_a554a30de6a6e582.manifest 45440 info: adding redirect microsoft.vc90.mfc version (9, 0, 21022, 8) -> (9, 0, 30729, 6161) 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 46588 info: looking eggs 46589 info: using python library c:\program files\anaconda2\python27.dll 46589 info: found binding redirects: [bindingredirect(name=u'microsoft.vc90.crt', language=none, arch=u'amd64', oldversion=(9, 0, 21022, 8), newversion=(9, 0, 30729, 6161), publickeytoken =u'1fc8b3b9a1e18e3b'), bindingredirect(name=u'microsoft.vc90.mfc', language=none, arch=u'amd64', oldversion=(9, 0, 21022, 8), newversion=(9, 0, 30729,  6161), publickeytoken=u'1fc8b3b9a1e18e3b')] 46601 info: warnings written c:\zmqtest\build\zmqtest\warnzmqtest.txt 46759 info: checking pyz 46760 info: building pyz because out00-pyz.toc non existent 46760 info: building pyz (zlibarchive) c:\zmqtest\build\zmqtest\out00-pyz.pyz 48335 info: building pyz (zlibarchive) c:\zmqtest\build\zmqtest\out00-pyz.pyz completed successfully. 48569 info: checking pkg 48571 info: building pkg because out00-pkg.toc non existent 48571 info: building pkg (carchive) out00-pkg.pkg 48609 info: building pkg (carchive) out00-pkg.pkg completed successfully. 48615 info: bootloader c:\program files\anaconda2\lib\site-packages\pyinstaller\bootloader\windows-64bit\run.exe 48617 info: checking exe 48617 info: building exe because out00-exe.toc non existent 48618 info: building exe out00-exe.toc 48618 info: appending archive exe c:\zmqtest\build\zmqtest\zmqtest.exe 48634 info: building exe out00-exe.toc completed successfully. 48644 info: checking collect 48644 info: building collect because out00-collect.toc non existent 48644 info: building collect out00-collect.toc 48673 info: redirecting microsoft.vc90.crt version (9, 0, 21022, 8) -> (9, 0, 30729, 6161) 51664 info: building collect out00-collect.toc completed successfully. 

content of .spec file:

# -*- mode: python -*-  block_cipher = none   = analysis(['zmqtest.py'],              pathex=['c:\\zmqtest'],              binaries=[],              datas=[],              hiddenimports=[],              hookspath=[],              runtime_hooks=[],              excludes=[],              win_no_prefer_redirects=false,              win_private_assemblies=false,              cipher=block_cipher) pyz = pyz(a.pure, a.zipped_data,              cipher=block_cipher) exe = exe(pyz,           a.scripts,           exclude_binaries=true,           name='zmqtest',           debug=false,           strip=false,           upx=true,           console=true ) coll = collect(exe,                a.binaries,                a.zipfiles,                a.datas,                strip=false,                upx=true,                name='zmqtest') 

and error when try start generated exe:

c:\zmqtest\dist\zmqtest>zmqtest.exe traceback (most recent call last):   file "zmqtest.py", line 1, in <module>   file "c:\program files\anaconda2\lib\site-packages\pyinstaller\loader\pyimod03_importers.py", line 396, in load_module     exec(bytecode, module.__dict__)   file "site-packages\zmq\__init__.py", line 34, in <module>   file "c:\program files\anaconda2\lib\site-packages\pyinstaller\loader\pyimod03_importers.py", line 396, in load_module     exec(bytecode, module.__dict__)   file "site-packages\zmq\backend\__init__.py", line 40, in <module>   file "site-packages\zmq\backend\__init__.py", line 27, in <module>   file "site-packages\zmq\backend\select.py", line 26, in select_backend   file "c:\program files\anaconda2\lib\site-packages\pyinstaller\loader\pyimod03_importers.py", line 396, in load_module     exec(bytecode, module.__dict__)   file "site-packages\zmq\backend\cython\__init__.py", line 6, in <module>   file "c:\program files\anaconda2\lib\site-packages\pyinstaller\loader\pyimod03_importers.py", line 687, in load_module     module = imp.load_module(fullname, fp, filename, ext_tuple) importerror: dll load failed: das angegebene modul wurde nicht gefunden. [4836] failed execute script zmqtest 

any idea how zmq running pyinstaller?

[info]

for wants follow 9dogs instruction , install latest version of pyinstaller with

pip install git+https://github.com/pyinstaller/pyinstaller.git 

make sure have git installed.

ok, figured out root cause zmq.backend.select imports several modules __import__ hidden pyinstaller dynamically loaded modules can idenified calling test python file in verbose mode:

python -v zmqtest.py 

in addition folder containing libzmq.pyd not found it's path has added manually. full pyinstaller call working me looks this:

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\pkgs\pyzmq-16.0.2-py27_0\lib\site-packages\zmq" ^              zmqtest.py 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -