Comprehensive tutorial on Pyinstaller? [closed]

不打扰是莪最后的温柔 提交于 2019-11-27 12:03:55

Both guides in the accepted answer seem outdated. PyInstaller now provides an executable script that allows you to do

pyinstaller your_script.py

wherever your_script.py is located -- instead of the old mode of copying your your_script.py to wherever you copied the source code of PyInstaller.

Here's a brief, more recent guide that walks you through a simple Hello World example:

http://www.pythoncentral.io/pyinstaller-package-python-applications-windows-mac-linux/

Have you looked here: simplified tutorial

Or here: a bit longer tutorial

EDIT: Adding data files is implied in the second tutorial. If you use the second example just before the "Wrapping Up" section, along with the official documentation: Analysis, it looks like you'd specify your data-file dependencies as part of the "datas" subobject when calling the Analysis() function.

EDIT2: From official documentation: "Generally, you will not need to create your own PKGs, as the EXE will do it for you. This is one way to include read-only data in a single-file deployment, however. A single-file deployment including TK support will use this technique."

Example (should be roughly like this):

a = Analysis(...)
pyz = PYZ(a.pure)
pkg = PKG(a.pure, name="PackageName")
exe = EXE(pyz, pkg,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          ...)

To Create one executable of your python script or project
create your script or project. To install pyinstaller on Windows type

pip install pyinstaller
Now open command prompt and type the command
pyinstaller --onefile myscripy.py
You will find a dist folder created. Browse dist folder and you will get .exe file of python script.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!