简体   繁体   中英

cx_Freeze generated Executable won't open

I've read many other cx_Freeze related issues on Stack Overflow and so far they've been beneficial, but I'm still not getting the executable to work.

When you click on the .exe file nothing happens.

I also made a square root calculator to try to figure out why it wouldn't work without any of the tkinter GUI that this one uses, but it doesn't work either.

They both work great in Python, but the .exe doesn't do anyting at all. I'm using Python 3.7 (32bit), cx_Freeze 5.1.1 (32bit), Windows 10 pro (64bit),

setup.py

import cx_Freeze
from cx_Freeze import setup, Executable
import tkinter
import ThreadCalc
import sys
import os

ba = None

if sys.platform == 'win32':
    ba = "Win32GUI"

if sys.platform == 'win64':
    ba = "Win64GUI"

os.environ['TCL_LIBRARY'] = r'C:\Python37-32\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Python37-32\tcl\tk8.6'

build_exe_options = {"include_msvcr": True}

ex = Executable(script="ThreadCalc.py", base = ba, targetName='CreoThreadNoteGenerator.exe')

cx_Freeze.setup(name = "CreoThreadNoteGenerator",
      options = {"build_exe":{"include_files":    ['small_logo.gif'],"includes":["tkinter","os","math","sys"]}},
      version = '0.1',
      description = 'Generates A Thread Quality Control Note for Creo',
      executables = [ex] )

SQUARE ROOT CALCULATOR

sqrt.py

import math

a = input('Enter a number to Evaluate')
x = math.sqrt(a)
print("The square root of {} is {}").format(a,x)

setup.py

import cx_Freeze
import os
import sys
import math
from cx_Freeze import setup, Executable


ba = None

if sys.platform == 'win32':
    ba = "Win32GUI"

ex = Executable(script="sqrt.py", base = ba, targetName='SquareRootCalc.exe')

cx_Freeze.setup(name = "SquareRootCalc",
  options = {"build_exe":{"packages":["os", "math", "sys"]}},
  version = '0.1',
  description = 'Square Root Calculator',
  executables = [ex] )

Have you tried to remove these two lines

if sys.platform == 'win32':
    ba = "Win32GUI"

(ie leaving ba(se) = None) in the SQUARE ROOT CALCULATOR example? See this question: After creating python exe file with cx_freeze the file doesn't do anything

For the first part of your question concerning the script with GUI/Tkinter: have a look at the corresponding example in the cx_Freeze package under (Python directory)\\Lib\\site-packages\\cx_Freeze\\samples\\Tkinter . If it still does not work, please provide a minimal example in order that anybody can help you further.

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