title: python-使用pyinstaller打包成可執行程式
categories: Python
tags: [python, pyinstaller]
date: 2020-05-14 17:22:56
comments: false
mathjax: true
toc: true
python-使用pyinstaller打包成可執行程式. 這裡使用的是 Python3.6
前篇
- 【Python】使用 PyInstaller 將 Python打包成 exe 檔 - https://medium.com/pyladies-taiwan/python-%E5%B0%87python%E6%89%93%E5%8C%85%E6%88%90exe%E6%AA%94-32a4bacbe351
流程
- 安裝 pyinstaller
$ pip3 install pyinstaller
- 打包. 指令:
pyinstaller -F xxx.py
會生成 build 和 dist 兩個目錄, 可執行程式在 dist 目錄下.e:\its_rummy\tools (rls-money-7324 -> origin) $ pyinstaller -F tinypng_win.py 70 INFO: PyInstaller: 3.6 71 INFO: Python: 3.6.5 ... 8750 INFO: Appending archive to EXE e:\its_rummy\tools\dist\tinypng_win.exe 9086 INFO: Building EXE from EXE-00.toc completed successfully.
pyinstaller 常用參數介紹
- -h : 檢視參數
- -F : 打包成一個 exe 檔案
- –icon : icon 圖檔
- -w : 使用視窗, 無控制台
- -c : 使用控制台, 無視窗
- -D : 建立一個目錄, 包含 exe 以及其他一些依賴性檔案
踩坑
找不到 tls 證書
報錯:
Could not find a suitable TLS CA certificate bundle
解決辦法: 從 Python 安裝目錄下找到
Lib\site-packages\certifi\cacert.pem
, 複制到程式能讀到的地方
代碼中加入:
重新打包即可.
參考: https://blog.csdn.net/qq_40770527/article/details/104847046