简体   繁体   English

使用 PyInstaller 将带有命令行参数的 Python 程序转换为可执行文件

[英]Converting Python program with command line argument into executable using PyInstaller

I would like to convert a python code with command line argument into windows executable using pyInstaller.我想使用 pyInstaller 将带有命令行参数的 python 代码转换为 Windows 可执行文件。 I run my python program as follows我运行我的python程序如下

python myPython 1

Firstly i wonder that you don't get articles related to to this in your Google search.首先,我想知道您在 Google 搜索中没有获得与此相关的文章。

First Install pyinstaller by running this command首先通过运行此命令安装 pyinstaller

pip install pyinstaller

For Additional Help https://pyinstaller.readthedocs.io/en/stable/installation.html如需其他帮助https://pyinstaller.readthedocs.io/en/stable/installation.html

Open command prompt, Now navigate to the directory in which your python file (using the cd command ) is located then enter the code打开命令提示符,现在导航到您的 python 文件(使用 cd 命令)所在的目录,然后输入代码

pyinstaller --onefile .py pyinstaller --onefile .py

This will create a standalone executable file (That i expect you are asking).这将创建一个独立的可执行文件(我希望你会问)。 Below is the link to a stackoverflow question you missed to read.以下是您错过阅读的 stackoverflow 问题的链接。 Edit : in the same directory a folder name dist will get created which have your single executable.编辑:在同一目录中,将创建一个名为 dist 的文件夹,其中包含您的单个可执行文件。

How can I convert a .py to .exe for Python? 如何将 .py 转换为 Python 的 .exe?

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM