我正在尝试使用cx_freeze为Windows正确构建Python。我选择此工具的原因是另一个类似py2win的工具具有最新的python版本问题(当前为3.7)。
但是当我编译应用程序时,我无法启动它。我遇到错误:
from bcrypt import _bcrypt ModuleNotFoundError: No module named '_cffi_backend'
我在github和stackoverflow上寻求帮助。我所做的是使用pip重新安装密码,paramiko和cffi软件包,如此处所述:No module named _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构建后,我得到了很长的输出并带有一些警告:
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中添加任何内容吗?你知道如何处理这个问题吗?我根本无法运行我的应用。
答案 0 :(得分:0)
我有同样的错误。 将“ _cffi_backend.cp36-win32.pyd”(或体系结构上的任何内容)从站点程序包复制到目标文件夹中对我来说很成功。也许是cx_freeze错误。
答案 1 :(得分:0)
build_options = {"includes": ["_cffi_backend"]}