python pyinstaller安裝

來源:互聯網
上載者:User

標籤:需要   aci   utf8   pytho   匯入模組   down   表徵圖   支援   tar   

需求分析:

python指令碼如果在沒有安裝python的機器上不能運行,所以將指令碼打包成exe檔案,降低指令碼對環境的依賴性,同時運行更加迅速。

當然打包的指令碼似乎不是在所有的win平台下都能使用,win7有一部分不能使用,我在win10能夠很好的運行。

準備:  

pyinstaller(http://www.pyinstaller.org/) 首先還是去官網看支援的python版本,不然會很尷尬的

安裝方法1:
安裝pyinstaller和pywin32
使用一下命令將自動安裝兩個包,在cmd用pip命令

pip install https://github.com/pyinstaller/pyinstaller/archive/develop.tar.gz

安裝方法二:

pip install pyinstaller   (會自動下載future,pywin32,pyinstaller)

如何使用Pyinstaller

方法一:
1.cmd到/python/scripts 找到pyinstaller.exe
2.輸入命令

1 pyinstaller.exe -F path:demo.py

方法二:
1.進入pyinstaller的解壓包,輸入命令
2."python pyinstaller.py -F path:demo.py"
從cmd最後一行輸出可尋找到產生的檔案

12468 INFO: Appending archive to EXE D:\Documents\Downloads\PyInstaller-3.2\download\dist\download.exe

 

後記:

1.程式設定自訂表徵圖:pyinstaller -F -i ico_path  py_path 

首先需要下載一張正常的ico,不能用直接修改尾碼的。

下載圖片:    https://www.easyicon.net

圖片改為ico:  http://www.ico.la/

輸入命令 pyinstaller -F -i "demo.ico" "main.py"

2.報錯提示:

pyinstaller -F -i "demo.ico" "main.py" 命令格式一定是先表徵圖路徑,再程式路徑。

路徑最好為英文,沒有中文字元;指令碼名稱裡沒有特殊字元如 .

使用utf8編碼

表徵圖檔案必須是正常格式,不能直接更改尾碼。

tuble index out of range ---》pyinstaller版本尚未支援python的版本

3.視窗程序

使用 pyinstaller -F -w  -i ico_path  py_path ,這樣指令碼不會彈出命令窗,前提是用了GUI庫. 

4.匯入模組問題

pyinstaller -F -w  -i  --hidden-import queue ico_path  py_path 加上選項

python pyinstaller安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.