首页 > 解决方案 > 打开 cx_Freeze 编译的 Python 应用程序时出现错误“没有名为 '_cffi_backend' 的模块”

问题描述

我正在尝试使用 cx_freeze 为 Windows 正确构建我的 Python。我选择这个工具的原因是另一个像 py2win 有最新(这次:3.7)python 构建的问题。

但是当我编译应用程序时,我无法启动它。我收到错误:

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

我在 github 和 stackoverflow 寻求帮助。我所做的是用 pip 重新安装密码学、paramiko 和 cffi 包,如下所述:没有名为 _cffi_backend 的模块。也许它对我不起作用,因为我使用的是 Python 3 而不是 2。

我的 setup.py 如下所示:

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")])

执行 python setup.py build 后,我得到了很长的输出和一些警告:

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.

完整日志粘贴在这里:https ://pastebin.com/SNXdBgnM

我应该在我的 setup.py 中添加任何内容吗?你知道如何处理这个问题吗?我根本无法运行我的应用程序。

标签: pythonpython-3.xwindowscx-freeze

解决方案


我有同样的错误。将“_cffi_backend.cp36-win32.pyd”(或您的架构上的任何内容)从站点包复制到目标文件夹对我来说是诀窍。也许是一个 cx_freeze 错误。


推荐阅读