我尝试使用cx_freeze
将.py文件转换为.exe,并且在构建时我没有遇到任何错误。我用另一个.py文件尝试了它并且它工作得很好,但这一次,它给了我这个错误:
Traceback (most recent call last):
File "C:\Users\Tilen\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\Users\Tilen\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "borzacommercial.py", line 6, in <module>
File "C:\Users\Tilen\AppData\Local\Programs\Python\Python36-32\lib\site-packages\bcrypt\__init__.py", line 25, in <module>
from bcrypt import _bcrypt
ModuleNotFoundError: No module named '_cffi_backend'
我该怎么办?
答案 0 :(得分:1)
导入_cffi_backend解决了这个问题
答案 1 :(得分:1)
当你收到一条消息说丢失了部分软件包时,首先要做的是尝试添加缺少软件包的名称。您可能会遇到更多错误,表示缺少其他模块,但也包含这些错误。您只需在packages
选项中添加包名称即可。像这样:
from cx_Freeze import setup, Executable
base = None executables = [Executable("borzacommercial.py", base=base)]
packages = ["idna", "_cffi_backend"]
options = { 'build_exe': { 'packages':packages, }, }
setup( name = "<any name>", options = options, version = "<any number>",
description = '<any description>', executables = executables )