在這個(gè)實(shí)戰(zhàn)案例中,我們將學(xué)習(xí)如何在Ubuntu系統(tǒng)下使用PyInstaller將Python腳本轉(zhuǎn)換為可執(zhí)行文件
sudo apt update
sudo apt install python3 python3-pip
pip3 install pyinstaller
hello_world.py
的文件,并添加以下內(nèi)容:print("Hello, World!")
hello_world.py
的文件夾,然后運(yùn)行以下命令:pyinstaller --onefile hello_world.py
這將創(chuàng)建一個(gè)名為dist
的新文件夾,其中包含一個(gè)名為hello_world
的可執(zhí)行文件。--onefile
選項(xiàng)表示將所有文件合并到一個(gè)可執(zhí)行文件中。
./dist/hello_world
你應(yīng)該會(huì)看到輸出 “Hello, World!”。
這就是在Ubuntu下使用PyInstaller將Python腳本轉(zhuǎn)換為可執(zhí)行文件的實(shí)戰(zhàn)案例。現(xiàn)在,你可以使用相同的方法將其他Python腳本轉(zhuǎn)換為可執(zhí)行文件。