Hello,

A finally found a workaround:

# coding: utf-8
from cx_Freeze import setup, Executable
import os
import sys

options = {"build_exe": {}}
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
if sys.platform == "win32":
    options["build_exe"]['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(
    # ...
    options=options,
)

Note: File name and path of `libcrypto` and ̀libssl` should be found with script instead hardcoded name.


Le 05/02/2019 à 20:48, Bastien Sevajol a écrit :
Hello,

cx_Freeze seems have trouble with python ssl lib on Windows. There is
an example script "test_ssl.py":

     import ssl
     print("Hello world")

When execute with python interpreter (eg. "python test_ssl.py"):

    C:\>python test_ssl.py
     Hello world

But, when build exe, with following "setup.py" (and with "python
setup.py build"):

     #!/usr/bin/env python
     # coding: utf-8
     import sys
     from cx_Freeze import setup, Executable

     # GUI applications require a different base on Windows (the default is for 
a
     # console application).
     base = None
     if sys.platform == "win32":
         base = "Console"

     setup(
         name="test_ssl",
         version="0.1",
         description="Test import ssl",
         author="",
         author_email="",
         url="",
         executables=[Executable("test_ssl.py", base=base)],
         options={"build_exe": {"packages": ["ssl"]}},
    )

When execute builded exe (test_ssl.exe):

     C:\build\exe.win-amd64-3.7>test_ssl.exe
     Traceback (most recent call last):
       File 
"C:\Python37\lib\site-packages\cx_Freeze\initscripts\__startup__.py",
line 14, in run
         module.run()
       File "C:\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py",
line 26, in run
         exec(code, m.__dict__)
       File "test_ssl.py", line 1, in <module>
       File "C:\Python37\lib\ssl.py", line 98, in <module>
         import _ssl             # if we can't import it, let the error 
propagate
     ImportError: DLL load failed: Le module spécifié est introuvable.

I'm using a Windows 10 Enterprise, version 1809. Python 3.7.1 and
cx_Freeze 5.1.1. Any idea about this ? Thank's a lot !


_______________________________________________
cx-freeze-users mailing list
cx-freeze-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cx-freeze-users

Reply via email to