简体   繁体   中英

.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. I tried it with another .py file and it worked perfectly, but this time, it gives me this error:

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. 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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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