1

I'm trying to build my Python up properly for Windows with cx_freeze. The reason I chose this tool is another ones like py2win have issues with newest (for this time: 3.7) python build.

But when I compile the app I cannot start it. I'm getting error:

from bcrypt import _bcrypt ModuleNotFoundError: No module named '_cffi_backend'

I was looking for help at github and stackoverflow. What I did was to reinstall cryptography, paramiko and cffi packages with pip, as described here: No module named _cffi_backend. Maybe it's not working for me, because I'm using Python 3 instead of 2.

My setup.py looks like following:

from cx_Freeze import setup, Executable
import os

os.environ['TCL_LIBRARY'] = r'C:\Users\Kamil\AppData\Local\Programs\Python\Python37-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\Kamil\AppData\Local\Programs\Python\Python37-32\tcl\tk8.6'

includes = ["paramiko"]

options =   {
            "includes": includes,
            }

setup(name = 'SIMail',
      version = "0.1",
      description = "SIMail nadzor routerow" ,
      options = {"SIMailGUI.exe" : options},
      executables = [Executable("SIMailGUI.py")])

After executing python setup.py build I've got long output with some warnings:

Missing modules:
? MySQLdb imported from peewee
? StringIO imported from six
? UserDict imported from asn1crypto._ordereddict
? __builtin__ imported from paramiko.py3compat
? __main__ imported from bdb, pdb
? _frozen_importlib imported from importlib, importlib.abc
? _frozen_importlib_external imported from importlib, importlib._bootstrap, importlib.abc
? _posixsubprocess imported from subprocess
? _uuid imported from uuid
? _winreg imported from platform
? cStringIO imported from asn1crypto.core, paramiko.py3compat
? collections.Mapping imported from peewee
? collections.MutableMapping imported from paramiko.hostkeys
? fcntl imported from paramiko.agent
? grp imported from shutil, tarfile
? gssapi imported from paramiko.ssh_gss
? java.lang imported from platform
? org.python.core imported from copy, pickle
? os.path imported from os, pkgutil, py_compile, tracemalloc, unittest, unittest.util
? playhouse._speedups imported from peewee
? posix imported from os
? psycopg2 imported from peewee
? psycopg2cffi imported from peewee
? pwd imported from getpass, http.server, posixpath, shutil, tarfile, webbrowser
? pymysql imported from peewee
? pysqlite2 imported from peewee
? pysqlite3 imported from peewee
? six.moves imported from cryptography.hazmat.backends.openssl.backend, cryptography.x509.general_name
? termios imported from getpass, tty
? thread imported from paramiko.win_pageant
? urllib.quote imported from asn1crypto._iri
? urllib.unquote imported from asn1crypto._iri
? urlparse imported from asn1crypto._iri
? vms_lib imported from platform
This is not necessarily a problem - the modules may not be needed on this platform.

Full log is pasted here: https://pastebin.com/SNXdBgnM

Shall I add anything to my setup.py? Do you know how to deal with this problem? I cannot run my app at all.

Asmoox
  • 592
  • 8
  • 23
  • Which version of `cx_Freeze` are you using? – jpeg Jan 25 '19 at 07:46
  • Possible duplicate of [Exe built with cx\_Freeze shows error when containing pysftp import](https://stackoverflow.com/questions/57210744/exe-built-with-cx-freeze-shows-error-when-containing-pysftp-import) – jpeg Aug 13 '19 at 13:42

2 Answers2

0

I had the same error. Copying "_cffi_backend.cp36-win32.pyd" (or whatever on your architecture) from site-packages to the destination folder did the trick for me. Maybe a cx_freeze bug.

Jan Win
  • 147
  • 1
  • 12
0
build_options = {"includes": ["_cffi_backend"]}

https://github.com/marcelotduarte/cx_Freeze/issues/581

alex
  • 165
  • 4