用cx_freeze创建python exe文件后,该文件不执行任何操作 [英] After creating python exe file with cx_freeze the file doesn't do anything

查看:50
本文介绍了用cx_freeze创建python exe文件后,该文件不执行任何操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用cx_freeze创建了一个python 3.2.2 exe文件。当我尝试运行exe文件时,没有任何反应。

I recently created used cx_freeze to create a python 3.2.2 exe file. When I tried to run the exe file nothing happened.

这是我的test.py文件的代码:

Here is the code for my test.py file:

print("hello world")

for i in range(5):
    print(i)

这是我的testSetup.py文件的代码:

Here is the code for my testSetup.py file:

from cx_Freeze import setup, Executable

exe = Executable(
   script="test.py",
   base="Win32GUI",
   targetName="Test.exe"
   )


setup(
    name = "Test",
    version = "0.1",
    description = "I wish programming was this easy",
    executables = [exe])

cx_freeze创建的生成目录有一个名为exe的文件夹.win32-3.2,其中包含以下文件:

The build directory that cx_freeze made has a folder called exe.win32-3.2 which has the files:

bz2.pyd

library.zip

python32.dll

Test.exe

unicodedata.pyd

bz2.pyd
library.zip
python32.dll
Test.exe
unicodedata.pyd

推荐答案

我的建议:


  1. set base = None (尝试:也许这就是您想要的吗? bas e = Win32GUI 确实隐藏了控制台-这在构建GUI时很有用)

  1. set base = None (try it: maybe that's all you want? base = Win32GUI does "hide" the console - this is useful when you're building a GUI)

在同一文件夹中用您的.exe制作一个批处理文件(带有.bat的文本文件),调用您的.exe:

In the same folder with your .exe make a batch-file (a text-file with .bat) calling your .exe:

这将进入您的批处理文件:

this goes into your batch-file:

name-of-your-app.exe %1

PAUSE

您将通过单击批处理文件来启动应用程序-它将保持控制台打开您可以修正错误/输出。

You'll start your app by clicking the batch-file - it keeps the console open so you're able to reed the errors/output.

这篇关于用cx_freeze创建python exe文件后,该文件不执行任何操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆