简体   繁体   English

使用cx_freeze将.py转换为.exe会导致错误

[英].py to .exe using cx_freeze causes error

I'm trying to convert .py file to .exe using cx_freeze and I get no errors while it's building. 我正在尝试使用cx_freeze将.py文件转换为.exe,并且在构建时没有出现错误。 I tried it with another .py file and it worked perfectly, but this time, it gives me this error: 我尝试了另一个.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'

What should I do? 我该怎么办?

导入_cffi_backend解决了此问题

When you get a message saying that part of a package is missing the first thing to do is to try adding the name of the missing package. 当您收到一条消息,提示缺少一部分程序包时,首先要做的就是尝试添加缺少的程序包的名称。 You may get further errors which say that further modules are missing but just include those as well. 您可能会得到进一步的错误,这些错误表明缺少其他模块,但也包括这些模块。 You can do this by simply adding the name of the package in the packages option. 您可以通过在packages选项中简单地添加包的名称来做到这一点。 Like this: 像这样:

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 )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM