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.
The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.
PyInstaller supports making executables for Windows, Linux, and macOS, but it cannot cross compile.
To your users, the app is self-contained. They do not need to install any particular version of Python or any modules. They do not need to have Python installed at all. The output of PyInstaller is specific to the active operating system and the active version of Python.
Just add --hidden-import=_cffi_backend
option when building with pyinstaller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With