使用pyinstaller将多个.py文件构建为单个可执行文件 [英] Build Multiple .py files into a single executable file using pyinstaller

查看:112
本文介绍了使用pyinstaller将多个.py文件构建为单个可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个由5个和6个.py文件组成的小型pyqt应用程序,现在我要构建它们并将其编译到一个主文件中,这意味着我必须从一个主窗口exe操作它们.我的.py文件彼此成功连接.我已经使用pyinstaller制作了可执行文件,问题是我将每个.py文件都构建到了自己的exe文件中,但是我想制作一个完整的exe文件. py文件起作用.如何将所有.py文件构建为一个exe文件.我进行了很多搜索,但无法解决问题.

I have made a small pyqt application of 5 and 6 .py files.Now I want to build them and compiled them in a single main file.Mean I have to operate them from one main window exe. My .py files are connected with each other successfully.I have used pyinstaller to make the executable file, the problem is I have build each .py file into its own exe file.But I want to make a single exe file through which whole.py files operate.How to build all .py files into a single exe file.I have searched a lot but unable to resolve my issue.

推荐答案

假设您有一个名为 create.py 的文件,例如

Suppose you had a file called create.py like

def square (num)
    return num ** 2 

同一目录中的另一个文件,称为 input.py

Another file in the same directory called input.py

from . import create
def take_input():
    x = input("Enter Input")
    return create.square(x)

最后是您的 main.py

from . import input
if __name__ == '__main__':
    ip = input.take_input()

您将调用命令-

pyinstaller --onefile main.py

然后pyinstaller会导入所有文件本身的所有依赖项

And pyinstaller will import all the dependencies of all the files itself

这篇关于使用pyinstaller将多个.py文件构建为单个可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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