0

This error appears after compiling my Python 2.7 project with cx_freeze : https://i.stack.imgur.com/xJKuT.jpg

I have the impression that the error comes from the package pycryptodome / pycryptodomex which is well installed since everything works before compiling with cx_freeze.

I tried to modify the import with :

from Crypto.Cipher import AES

Instead of :

from Cryptodome.Cipher import AES

But there is always the same error..

Here are my build options on cx_freeze :

build_options = {
    'packages': ['jinja2.ext'],
    'namespace_packages':['zope'],
    'includes': ['zope.interface', 'M2Crypto'],
    'excludes': ['Tkinter']
}

I will be happy to try other solutions if you have ideas, thanks !

Antoine
  • 1
  • 1
  • Looking at your error message, a (shared) C/C++ library loaded by `pycryptodome` (is there something such as `pycryptodome_raw_lib`?) is probably missing from the build directory. You need to include this library manually using the `include_files` entry of `build_options`. – jpeg Oct 12 '18 at 07:57
  • There is no `pycryptodome_raw_lib` at all, which library do you suggest to include ? Knowing that cryptodome is well included by cx_freeze in lib directory after compilation – Antoine Oct 15 '18 at 16:09
  • I agree. I've looked closer to the traceback you've posted, it seems that something goes wrong during the import of `cffi`. You could try to add a print statement for debugging purpose in the `os.path.basename` function in `ntpath.py` before line 208 to find out more. One possibillity is that a log file cannot be created. Another possibility is that `cffi` seems to have a mechanism to recompile modules as necessary at runtime. This probably does not work properly once the application is frozen and thus needs to be done prior freezing. See my answer and the links therein. – jpeg Oct 15 '18 at 19:45

1 Answers1

0

Try to modify the import (in your main script or importing module) as

import cffi
import _cffi_backend
from Cryptodome.Cipher import AES

If this does not work, try to add 'cffi' and '_cffi_backend' to the includes list in your setup script.

If this still does not work, see the cffi documentation and this resource for further suggestions.

jpeg
  • 2,372
  • 4
  • 18
  • 31
  • I tried to add these imports with `cffi` in `includes` but always the same error :( I looked at the site that you sent but I don't see anything that can help me fix this error – Antoine Oct 16 '18 at 15:45