如何使用所有其他脚本将python项目转换为可执行文件? [英] How to convert a python project into an executable file with all additional scripts?

查看:88
本文介绍了如何使用所有其他脚本将python项目转换为可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经对此提出了很多问题,但是没有一个问题真正对我有帮助.让我解释整个项目场景,以便更好地解决我的问题.目录结构如下所示:

I know there have been a bunch of questions already asked regarding this but none of them really helped me. Let me explain the whole project scenario so that I provide a better clarity to my problem. The directory structure is somewhat like this shown below:

项目目录布局

我需要将整个基于GUI的项目(主文件使用Tkinter模块创建GUI)转换为main.exe,我可以与他人共享,同时确保所有其他文件的工作方式与工作方式完全相同现在,当我通过命令提示符运行此main.py时.当我将此命令与pyinstaller一起使用时-

I need to convert this whole GUI based project (The main file is using Tkinter module to create GUI) into main.exe which I can share with others while making sure that all the additional files work exactly the same way it is working now when I run this main.py via Command Prompt. When I use this command with pyinstaller -

"pyinstaller --onefile --noconsole main.py"

它将创建main.exe,该文件在运行时显示无法执行脚本".请为我提供详细说明,以说明我为达到上述目的而应该采取的措施.预先谢谢你.

It creates main.exe which shows "Failed to execute script" on running. Please provide me a detailed explanation on what should I do to achieve what I have stated above. Thank you in advance.

推荐答案

pyinstaller使用一些肮脏的技巧将一堆文件压缩为一个文件

pyinstaller uses a few dirty tricks to compress a bunch of files into one

我建议使用cx_Freeze代替inno setup installer maker

I recommend using cx_Freeze instead along with inno setup installer maker

执行pip install cx_Freeze进行安装,然后在此处进行设置

do pip install cx_Freeze to install that and go here for inno setup

然后将以下内容复制到与项目相同的文件夹中名为setup.py的文件中

then copy the following into a file named setup.py in the same folder as your project

from cx_Freeze import setup, Executable

setup(name = "YOUR APP NAME" ,
      version = "1.0.0" ,
      description = "DESCRIPTION" ,
      executables = [Executable("PYTHON FILE", base = "Win32GUI")]
)

最后运行python setup.py build

如果要作为一个文件下载此文件,请此处

if you want as onefile download this file here

只需稍微编辑文件,然后使用inno编译器制作安装程序

just edit the file a bit and use inno compiler to make into installer

这篇关于如何使用所有其他脚本将python项目转换为可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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