<p>我建议首先阅读模块本身的<strong><a href="https://pythonhosted.org/PyInstaller/#using-pyinstaller" rel="noreferrer">Using Pyinstaller section in the documentation</a></strong>。</p>
<p>您还可以使用一些教程(例如<a href="https://mborgerson.com/creating-an-executable-from-a-python-script" rel="noreferrer">Matt Borgerson's one</a>)。</p>
<p>为了概括一下,您应该:</p>
<ul>
<li><strong>编写脚本并确保它有效</li>
<li><p>从<strong>命令行运行:</p>
<p>~\pyinstaller<em>您的文件名</em>.py</p></li>
<li><p>此命令将生成一个<em>您的文件名</em>.spec文件,您可以在其中包含应用程序所需的所有dll和任何自定义设置(<a href="https://pythonhosted.org/PyInstaller/#using-spec-files" rel="noreferrer">Using Spec Files</a>)</p></li>
<li><p>一旦决定在.exe应用程序中包含什么,就可以从命令行运行</p>
<p>~\pyinstaller[<em>选项1</em>][<em>选项2</em>]<em>您的文件名</em>.py</p></li>
</ul>
<p>您可以在文档中找到<a href="https://pythonhosted.org/PyInstaller/#options" rel="noreferrer"><strong>options</strong></a>的完整列表。例如,<em>pyinstaller.exe--onefile--windowed--icon=app.ico app.py</em>其中:</p>
<ul>
<li>--one file:创建一个一个文件绑定的可执行文件。</li>
<li>--windowed:用于选择是否在Mac OS X或Windows中编译的参数</li>
<li>--icon=:选择要用作文件图标的文件。</li>
</ul>
<p>也可以使用<strong><a href="http://www.py2exe.org/index.cgi/Tutorial" rel="noreferrer">py2exe</a></strong>轻松创建exe文件。</p>