繁体   English   中英

cx_Freeze生成的可执行文件无法打开

[英]cx_Freeze generated Executable won't open

我已经阅读了关于Stack Overflow的许多其他与cx_Freeze相关的问题,到目前为止它们是有益的,但是我仍然无法使可执行文件正常工作。

当您单击.exe文件时,没有任何反应。

我还做了一个平方根计算器,试图弄清楚为什么没有该人使用的任何tkinter GUI都无法使用它,但是它也不起作用。

它们都可以在Python中很好地工作,但是.exe根本不执行任何操作。 我正在使用Python 3.7(32位),cx_Freeze 5.1.1(32位),Windows 10专业版(64位),

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] )

平方根计算器

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] )

您是否尝试删除了这两行

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

(即,离开ba(se)= None)在SQUARE ROOT CALCULATOR示例中? 看到这个问题: 用cx_freeze创建python exe文件后,该文件不执行任何操作

对于与GUI / Tkinter脚本有关的问题的第一部分:请看cx_Freeze包中(Python目录)\\ Lib \\ site-packages \\ cx_Freeze \\ samples \\ Tkinter下的相应示例。 如果仍然无法使用,请提供一个最小的示例,以便任何人都能进一步帮助您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM