[英]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.