cx_Freeze, "ImportError DLL load failed"

2

I created a code for an interface with Tkinter , reportlab , openpyxl among others. Everything inside my .py file works very well but when creating an executable (.exe) with cx_Freeze the following error occurs:

I appreciate any help. : D

The setup.py I did is this:

Hello. I have managed to make it work but now I have the following problem and I do not know how to solve it, thanks.

    
asked by Karen Martinez 24.08.2017 в 01:27
source

1 answer

0

You still need to include both dll files, in your case they are supposed to be located in:

  

C: \ Program Files \ Python35-32 \ DLLs

Check that this directory exists and that it contains the files:

  

tk86t.dll
  tcl86t.dll

The following setup.py should not give any problem (tested in Python 3.5 and 3.6 with cx_Freeze 5.0.2 and a simple app in Tkinter in Windows 10 .):

import os
import sys
import cx_Freeze

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))


os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')



include_files = [os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
                 os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll')]

executables = [cx_Freeze.Executable("programa1.py",
                                    base = "Win32GUI",
                                    icon = None)]

options = {"build_exe": {"packages": [],
                         "includes": [],
                         "include_files": include_files
                         }
           }

cx_Freeze.setup(
    name = "PDF",
    version = "1.0",
    description = "Formulario a PDF",
    options = options,
    executables = executables)

Make sure that when you execute setup.py build in CMD you call the right interpreter (important if you have different versions of Python installed), in your case it should be:

py -3.5-32 setup.py build

or directly:

"C:\Program Files\Python35-32\python" setup.py build
    
answered by 25.08.2017 в 01:28