使用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