在這個實戰案例中,我們將學習如何在Ubuntu系統下使用PyInstaller將Python腳本轉換為可執行文件
sudo apt update
sudo apt install python3 python3-pip
pip3 install pyinstaller
hello_world.py
的文件,并添加以下內容:print("Hello, World!")
hello_world.py
的文件夾,然后運行以下命令:pyinstaller --onefile hello_world.py
這將創建一個名為dist
的新文件夾,其中包含一個名為hello_world
的可執行文件。--onefile
選項表示將所有文件合并到一個可執行文件中。
./dist/hello_world
你應該會看到輸出 “Hello, World!”。
這就是在Ubuntu下使用PyInstaller將Python腳本轉換為可執行文件的實戰案例?,F在,你可以使用相同的方法將其他Python腳本轉換為可執行文件。