0

I’m trying to convert from .py to exe using cx_Freeze I made a setup.py code:

application_title = "Test_v_1.1"
main_python_file = "Test_V_1.py"
import sys
from cx_Freeze import setup,Executable

base = None
if sys.platform == "win32":
    base ="Win32GUI"

includes=["atexit","re"]


setup(
        name=application_title,
        version = "0.1",
        description ="Simle Test",
        options={"build_exe":{"includes":includes}},
        executables = {Executable(main_python_file, base = base)})

I add the code below to my setup.py and got the error ImportError: DLL load failed: The specified module could not be found.`

import os
os.environ['TCL_LIBRARY'] = r'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\tcl\tk8.6'

I have tried to use pyinstaller but sins my cmd give me the error of PyInstaller name not found and my python don't want to uninstall pip 9.0.1 get stuck at the "uninstalling" phase I stared with a different way of converting my .py

Tania Rheeder
  • 545
  • 1
  • 6
  • 10
  • `so.environ`? I assume it was just a typo? – Henry Yik May 17 '19 at 10:25
  • Typo, My apologies – Tania Rheeder May 17 '19 at 10:29
  • Please see [KeyError: 'TCL_Library' when I use cx_Freeze](https://stackoverflow.com/q/35533803/8516269) and [Getting “ImportError: DLL load failed: The specified module could not be found” when using cx_Freeze even with tcl86t.dll and tk86t.dll added in](https://stackoverflow.com/q/52246748/8516269). See [this answer](https://stackoverflow.com/a/52811346/8516269) for a solution of both error messages you mention which should work for cx_Freeze 5.1.1. – jpeg May 17 '19 at 11:20
  • Possible duplicate of [KeyError: 'TCL\_Library' when I use cx\_Freeze](https://stackoverflow.com/questions/35533803/keyerror-tcl-library-when-i-use-cx-freeze) – jpeg May 17 '19 at 11:22

1 Answers1

0

It looks like you are just missing the DLLs. Try include them in your setup config.

include_files = [r"C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\DLLs\tcl86t.dll",
             r"C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32\DLLs\tk86t.dll"]

setup(
        name=application_title,
        version = "0.1",
        description ="Simle Test",
        options={"build_exe":{"includes":[],"include_files":include_files}},
        executables = {Executable(main_python_file, base = base)})
Henry Yik
  • 22,275
  • 4
  • 18
  • 40