python pyinstaller


一、環境

windows 10 x64

python 3.6.6 x64


二、安裝pyinstaller

pip install pyinstaller


三、基本用法

pyinstaller hello.py


四、常用參數

-F 表示生成單個可執行文件(盡量不使用,打包成單個文件后,程序啟動時間較長)

-w 表示去掉控制台窗口

-p 表示你自己自定義需要加載的類路徑(如果有多個文件需要加這個參數,還可以指定site-packages路經)

-i  表示可執行文件的圖標(這個對圖標格式有要求,之前一直不起作用,換了張64x64 ico圖標就行了)

五、常見問題

5.1、python3.7使用pyinstaller 不能正常運行

Fatal Python error: initfsencoding: unable to load the file system codec

zipimport.ZipImportError: can't find module 'encodings'

Current thread 0x000011c0 (most recent call first):

clipboard

看到stackouerflow上說 pyinstaller 目前對python3.7支持不好,推薦使用python3.3 ~ python 3.6

https://stackoverflow.com/questions/48872724/pyinstaller-doesnt-work-in-python-3-7-cant-find-module-encodings

重新安裝python3.6在打包就可以了

clipboard


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM