使用 Nuitka 编译 Python 程序
Nuitka 官网:nuitka.net
-
安装 Nuitka 包
pip install nuitka -
写一个示例 Python 程序
vim main.pydef talk(message): return "Talk " + message def main(): print(talk("Hello World")) if __name__ == "__main__": main() -
使用 Nuitka 编译 Python 程序
python -m nuitka main.py -
第一次编译时 Nuitka 会询问你是否允许下载 Ccache 加速编译,回答
y:Nuitka will make use of ccache to speed up repeated compilation. Is it OK to download and put it in '/Users/username/Library/Caches/Nuitka/downloads/ccache/v4.2.1'. Fully automatic, cached. Proceed and download? [Yes]/No : y -
编译完成,编译产物为
main.bin。运行编译产物:$ ./main.bin Talk Hello World

浙公网安备 33010602011771号