title: python- Use pyinstaller to package into executable programs
categories: Python
tags: [python, pyinstaller]
date: 2020-05-14 17:22:56
comments: false
mathjax: true
toc: true
python- Use pyinstaller to package into an executable program. Python 3.6 is used here
Prequel
- [Python] Use PyInstaller to package Python into an exe file-https://medium.com/pyladies-taiwan/python-%E5%B0%87python%E6%89%93%E5%8C%85%E6%88%90exe %E6%AA%94-32a4bacbe351
Process
-
Install pyinstaller
$ pip3 install pyinstaller
-
Packaging. Command:
pyinstaller -F xxx.py
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.
Two directories, build and dist , will be generated , and the executable program is in the dist directory.
Introduction to pyinstaller common parameters
- -h: view parameters
- -F: packaged into an exe file
- --Icon: icon images
- -w: use windows, no console
- -c: use the console, no window
- -D: Create a directory, containing exe and other dependent files
Step on the pit
Could not find tls certificate
Error: Could not find a suitable TLS CA certificate bundle
Solution: Find it from the Python installation directory Lib\site-packages\certifi\cacert.pem
and copy it to a place where the program can read
Add in the code:
os.environ['REQUESTS_CA_BUNDLE'] = os.path.join(SelfPath, 'cacert.pem') # cacert.pem 路径
Just repack it.
Reference: https://blog.csdn.net/qq_40770527/article/details/104847046