目的:
使用pyinstaller将python打包成可執行檔案(exe)
問題:
在指令行中,執行 pyinstaller -F D:\program learning\python\studentsystem\studentsystem.py,出現如下錯誤資訊
圖1
問題分析
pyinstaller -F D:\program learning\python\studentsystem\studentsystem.py
由于路徑中存在空格,指令被解析為 pyinstaller -F D:\program 導緻沒有找到要打包的檔案,這一點從圖1中的最後一行
valueError: script 'D:\program' not found 可以看出來。(把D:\program當作要被打包的python腳本了)
解決方案
将腳本路徑包含在一對雙引号中,如下:
pyinstaller -F “D:\program learning\python\studentsystem\studentsystem.py”
驗證效果
圖2