# 打包 selenium 程式到 exe ###### tags: `問題記錄`,`Python` * **問題記錄** 在新環境裝了最新版本的 selenium 和 pyinstaller pyinstaller -F 執行後可產生 dist 資料夾, 底下也有 .exe 檔, .exe 執行後也可正常運作 唯一奇怪的是: 執行完程式流程後, 就立即 **閃退** (正常運作下不會自動關閉)   已排除下列可能: (1) chromedriver 版本不匹配 (2) 新套件: 使用的舊版語法 deprecated   猜是版本依賴的問題   解法: 找到舊環境中,會用到的套件版本(如下) 指定版本 >> 重裝套件 >> workable! * **Package dependencies** ``` pip install selenium==3.141.0 pip install pyinstaller==5.4.1 ``` * **Example: Create an .exe file by "single" Python file** ``` cd C:\code\test pyinstaller -F test.py -i C:\image\test_img.ico ```