--- tags: ithelp --- # day 9 打包 python 程式 如果希望在別台電腦上可以執行自己寫的python 程式, 而不需要重新安裝所有套件,打包是一個比較好的選擇。 這裡使用 pyinstaller 進行打包。 ```shell conda install pyinstaller ``` 安裝完後,使用 pyinstaller 打包自己的主程式 ``` pyinstaller a01_flask_server.py ``` 執行完後會出現幾個資料夾 build, dist, build 是包裝時的生成的一些紀錄和文件, 而 dist 會包含打包結果。 預設模式會將程式和函式庫放入同名資料夾,並將程式包裝成可執行檔。 ![](https://i.imgur.com/1AkzKqz.png) 如果是簡單的 python 程式,做到這裡就算成功... 但打包 python 可是有非常多坑的。 ![](https://i.imgur.com/qGyC3Pg.png) 明天會試著一個一個解決碰上的問題。