一、安裝Pyinstaller和Pywin32
參考鏈接1:https://www.cnblogs.com/gopythoner/p/6337543.html
參考鏈接2:https://www.cnblogs.com/zyt-bg/p/10937634.html
Pyinstaller官方網(wǎng)站:http://www.pyinstaller.org/
注意:Pyinstaller版本需要對應python版本。親測python2.7.15可以使用3.4版本的Pyinstaller
打包生成exe的路徑:I:\pyInstaller_for_2.7.15\1\pyinstaller-3.4\main\dist
通常打包方式:
正式打包前先進行debug
python pyinstaller.py -D xxx.py 生成debug模式的exe
然后在cmd模式下運行該exe文件命令:.\xx.exe,直接雙擊會閃退看不到debug信息,通常需要查看自己哪些包遺漏了。
python pyinstaller.py -F -w xxx.py 生成正式的exe
記錄一下遇到的坑問題:
坑1因為pefile模塊導致安裝失敗問題:
win10,python2.7.15安裝pyinstaller3.4出現(xiàn)錯誤。
使用的是官網(wǎng)下載的安裝包.zip解壓后使用python setup.py install方式。
看了下問題好像是profile這個模塊有問題,安裝pefile模塊失敗了。
pyinstaller需要的模塊:
結(jié)果自己安裝這個模塊也失敗了
然后去百度了下其他版本因為版本要大于等于2017.8.1隨意就選了2017.9.3這個版本,這下安裝就沒啥問題了。這下試試繼續(xù)安裝pyinstaller。
重新執(zhí)行python setup.py install成功。
坑2
pyinstaller每次打包文件名都不能一樣,不然還是打包上次打包的文件。