使用ssl模块的cx_Freeze构建的应用程序在启动时崩溃

问题描述 投票:0回答:1

启动生成的.exe文件时,将打印以下消息:

  Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\Program Files\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "Application.py", line 8, in <module>
    from nats.aio.client import Client as NATS
  File "C:\Program Files\Python37\lib\site-packages\nats\__init__.py", line 16, in <module>
    from .aio.client import Client as NATS
  File "C:\Program Files\Python37\lib\site-packages\nats\aio\client.py", line 18, in <module>
    import ssl
  File "C:\Program Files\Python37\lib\ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
python cx-freeze
1个回答
0
投票

python _ssl.pyd需要一些需要在setup.py中明确包含的DLL

import os.path
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
build_exe_options = {"include_files" : [
    os.path.join(PYTHON_INSTALL_DIR, "DLLs", "libcrypto-1_1-x64.dll"),
    os.path.join(PYTHON_INSTALL_DIR, "DLLs", "libssl-1_1-x64.dll")]}

setup(  name = "Application",
        version = "0.1",
        description = "Application",
        options = {"build_exe": build_exe_options},
        executables = [Executable("app.py", base=None)])
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.