Generated windows exe (pyinstaller) could not load _cffi_backend
Asked Answered
E

1

7

I am trying to generate executable(x86) with pyinstaller(3.0) on windows7(x64). I have installed cffi and other needed packages with pip. I can import cffi and _cffi_backend module successfully from command line:

>>> import cffi
>>> import _cffi_backend
>>> cffi.__file__
'C:\\Program Files (x86)\\Python27\\lib\\site-packages\\cffi\\__init__.pyc'
>>> _cffi_backend.__file__
'C:\\Program Files (x86)\\Python27\\lib\\site-packages\\_cffi_backend.pyd'

>

While trying to run generated executable I got error below:

  File "C:\Program Files (x86)\Python27\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 13, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
  File "c:\program files (x86)\python27\lib\site-packages\PyInstaller-3.0-py2.7.egg\PyInstaller\loader\pyimod03_importers.py", line 517, in load_module
    module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: No module named _cffi_backend

You may see full startup log here.

By the way, I have compiled libcffi library with mingw and got a DLL file. Then copied to one of the library path and I got same error on application startup again.

I do not know why _cffi_backend library could not be loaded on application startup even it exists and in python path. I am not good at python and unfortunately I am stuck on this almost 2 days, any suggestion and guidence will be appreciated.

Thanks.

Exclusive answered 4/12, 2015 at 0:3 Comment(2)
is there anybody could give any suggestion?Exclusive
Have you checked this question before? The answer might help you: ImportError from compiled source codePectoralis
E
9

Just add --hidden-import=_cffi_backend option when building with pyinstaller.

Electrophysiology answered 20/4, 2016 at 16:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.