Python 2.7.16 pyinstaller3.0 生成exe可執行文件


背景:

本人用python2.7+pyqt4 寫了一個記錄儀器log的帶界面的小程序,要拿到客戶電腦上用,必須要打包成可執行文件才行!

 

========================================================

找方法:

網上搜了一下很簡單,pyinstaller -F xxx.py 就能生成夢寐以求得可執行文件了

第一步:打開dos,直接輸入命令 "pip install pyinstaller" 安裝 pyinstaller,但事與願違直接報錯,

ERROR: Command errored out with exit status 1: 'c:\python27amd64\python.exe' 'c:\python27amd64\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'c:\users\welu1\appdata\local\temp\tmphbreil' Check the logs for full command output.(什么鬼完全不曉得啥意思)

上網搜了好久,說是新版本得pyinstaller(目前是4.0版本)與python2.7不兼容了,只能安裝pyinstaller 3.0版本,那只能手動下載安裝包文件了,下載地址:https://pypi.org/project/pyinstaller/3.0/#files

下載完成后是  PyInstaller-3.0.tar.gz 文件,解壓縮后通過cmd進入到 C:\...\dist\PyInstaller-3.0目錄下, 執行 python setup.py install 命令就可以安裝了

=============================================

結果:

大功告成,可以打包了,通過cmd進入到需要打包的文件目錄,執行命令 pyinstaller -F xxx.py,在當前目錄的dist目錄下成功生成 exe文件,雙擊可以正常運行

但是有一個問題,總是有個黑色框一起出現,很難看,於是又查找方法,解決方法是打包時增加參數-w:pyinstaller -F -w xxx.py 

 


免責聲明!

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



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