如何使用pyinstaller? [英] How to use pyinstaller?
问题描述
好吧,所以我是编程中的一个完整的noob,我试图编译一个简单的程序,我写了一个字符串和打印出的morse代码中的字符串,它叫做morse.py。我安装了pyinstaller使用
pip install pyinstaller
我试图使用pyinstaller编译我的程序。
现在我搜索了一下,它说我需要写pyinstaller morse.py,但我真的不知道在哪里写。我试图移动到我的程序的目录,并在CMD,但它没有工作。我试着在同一个目录下做一个python程序,这样做,也没有工作。我找不到任何非常有帮助的告诉我具体如何编译文件。
有人可以帮忙吗?
请阅读模块本身的 文档中的使用Pyinstaller一节。
您也可以使用一些教程(例如 Matt Borgerson的一个)。
为了回顾你应该:
- 写您的脚本并确保其有效
-
strong>命令行:
-
此命令将生成一个 your_file_name .spec文件,您可以在其中添加应用程序所需的所有dll和任何自定义设置(
您可以从命令行运行的.exe应用程序
〜\ pyinstaller [ option1 your_file_name .py
您可以在 选项 。示例可以是 pyinstaller.exe --onefile --windowed --icon = app.ico app.py 其中:
- - 一个文件:创建一个单文件绑定的可执行文件。
- - windowed:在Mac OS X或Windows中编译时选择的参数
- - icon =:选择要用作文件图标的文件。
您可以非常轻松地创建exe文件还可以使用 py2exe 。
Okay so I'm a complete noob in programming and I'm trying to compile a simple program I wrote that takes in a string and prints out the string in morse code it's called morse.py. I installed pyinstaller using
pip install pyinstaller
and I am trying to compile my program using pyinstaller.
Now I've searched a bit and it says that I need to write pyinstaller morse.py, but I don't really know where to write that. I tried moving to the directory of my program and doing that in CMD but it didn't work. I tried making a python program in the same directory and doing that and that also didn't work. I couldn't find anything very helpful to tell me exactly how to compile the file.
Can someone please help?
I would suggest to first read the Using Pyinstaller section in the documentation of the module itself.
You can also use some tutorials (e.g. Matt Borgerson's one).
In order to recap you should:
- write your script and make sure that it works
run from the command line:
~\ pyinstaller your_file_name.py
this command will generate a your_file_name.spec file where you can include all the dll required by your application and any custom settings (Using Spec Files)
once you have decided what to include in your .exe application you can run from the command line
~\ pyinstaller [option1] [option2] your_file_name.py
You can find the full list the options in the documentation. An example could be pyinstaller.exe --onefile --windowed --icon=app.ico app.py where:
- --onefile: Create a one-file bundled executable.
- --windowed: Parameter to chooseif you are compiling in Mac OS X or Windows
- --icon= : Choose the file to use as icon for file.
You can create your exe file very easily also with py2exe.
这篇关于如何使用pyinstaller?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!