简体   繁体   English

如何将两个 python 文件合并为一个 exe 文件

[英]how can I combine two python files into one exe file

I am coding a calculator, how can I combine two python files into one exe file?我正在编写计算器,如何将两个 python 文件合并为一个 exe 文件? I have 2 files, one is a program shell, question-answer, and the second file is a collection of functions in which formulas for solving examples are written.我有2个文件,一个是程序shell,问答,第二个文件是函数集合,其中编写了求解示例的公式。

As long as you import the second file from the main file, you can use PyInstaller.只要从主文件中导入第二个文件,就可以使用 PyInstaller。

main.py

import second

# ...

second.py

print('Hello World!')

You can install PyInstaller with the command pip install pyinstaller .您可以使用命令pip install pyinstaller After that, run pyinstaller --onefile main.py to create the executable.之后,运行pyinstaller --onefile main.py来创建可执行文件。

If You are trying to compile python file into one exe, You should consider using pyinstaller.如果您尝试将 python 文件编译成一个 exe,您应该考虑使用 pyinstaller。

pyinstaller --onefile script.py

,where script.py is the main file. ,其中 script.py 是主文件。 More here: Python to EXE file in one file更多信息: Python 到一个文件中的 EXE 文件

暂无
暂无

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

相关问题 python将两个文本文件合并到一个文件中 - python combine two text files to one file 如何将 Python 文件与多个数据文件转换为.exe 格式? - How can I convert Python file with data files more than one to .exe format? 如何使用python将多个Excel文件中的数据合并到一个Excel文件中? - How can I use python to combine data from multiple excel files into one excel file? 如何将多个 CSV 文件与 Python 和 Pandas 合并为一个? - How can I combine multiple CSV files into one with Python and Pandas? 如何通过将第一个列的末尾添加一列,将两个csv文件合并为一个? - How can I combine two csv files into one, by adding one column to the end of the first one? Python:如何将两个 .txt 文件合二为一并自行生成其 .txt 文件 - Python: how to combine two .txt files into one and self-generate its .txt file 如何在文本文件中追加数据并使用 python 将多个文本文件合并为一个文本文件? - How do I append the data in text files and combine multiple text files into one text file using python? 我可以在Python中将两个装饰器组合为一个吗? - Can I combine two decorators into a single one in Python? 如何使用一个 Python 程序将另一个程序转换为 exe 文件? - How can I use one Python program to turn another one into an exe file? python - 如何在带有pandas的Python中将同一个excel文件的两个选项卡合并到一个选项卡中? - How do I combine two tabs of the same excel file into one tab in Python w/ pandas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM