今天瓦特歐要來介紹,如何製作python執行檔(exe file),甚麼時候需要執行檔呢?
答案是:當您寫好的程式,想要傳遞給其他人使用,但是又不確定對方是否有python程式執行的環境,或者您想要將寫好的程式,製作成小工具帶在身上
到處去執行?。
PS:執行檔維基百科連結:執行檔
此時就能參考我接下來的介紹,將寫好的程式打包成exe。?
首先請大家打開,Anaconda Prompt安裝 pyinstaller,不知道甚麼是Anaconda Prompt的朋友請看這篇: [TIL#1] Python 自學 day1 Anaconda
Step1: 打開Anaconda Prompt,輸入pip install pyinstaller

安裝完成會出現:

Step2: 寫好想打包的程式碼,瓦特歐用,[TIL#3] Python 自學 day3 流程控制,用終極密碼來打包作範例?,打開記事本重新命名為,GuessNumber.py,輸入以下程式碼:

Step3: 用Anaconda Prompt執行GuessNumber.py,在anaconda prompt輸入python GuessNumber.py,看是否程式碼功能正常?

Step4: 輸入指令打包程式碼,製作執行檔,輸入pyinstaller -F “GuessNumber.py”

打包完成:

Step5: 去製作執行檔完成的資料夾,找打包好的執行檔!
以我的路徑就是:F:\python-practice\dist

Step6:執行看看吧~

感謝今天的收看,這就是今天製作執行檔的介紹~?
瓦特歐Python介紹系列:
[TIL#1] Python 自學 day1 Anaconda
[TIL#2] Python 自學 day2 變數
[TIL#3] Python 自學 day3 流程控制
[TIL#4] Python 自學 day4 製作執行檔
[TIL#5] Python 自學 day5 執行檔更換icon
[TIL#6] Python 自學 day6 PIL浮水印、圖片大小變更
[TIL#7] Python 自學 day7 大量圖片Resize 處理 懶人包
[TIL#8] Python 自學 day8 GUI製作- 使用Tkinter Grid管理器
[TIL#9] Python 自學 day9 GUI製作 放入圖片 grid 版本
[TIL#10] Python 自學 day10 創造圖片的拼貼
[TIL#11] Python 自學 day11 matplotlib 統計圖、長條圖、圓餅圖、散佈圖
1 Comments