py文件转可执行文件

发布时间 2023-03-22 21:11:46作者: 心比天高xzh

使用Python官方提供的pyinstaller库。

pip3 install pyinstaller
pyinstaller -F nameofpy (-n nameofoutput)

使用示例
在hello.py所在目录下执行pyinstaller -F hello.py会在目录中产生dist文件夹,下有名为hello的可执行文件(不指定输出名时默认为py文件前缀)。
当然也可以执行pyinstaller -F hello.py -n hello1,会在目录中产生dist文件夹,下有名为hello1的可执行文件。
使用方式:python3 hello.py argu1 argu2等同于./hello argu1 argu2