2020.11.27
Because the daughter-in-law needs a large number of tables in her work, so I use Python to develop a small tool to deal with Excel tables (the first version of the current function is less, more bugs). My development environment is in the Mac system, and then in the Window package into a 64-bit and 32-bit general EXE program, this paper mainly introduces the packaging process and matters for attention.
In the process of learning, if there is a mistake, hope to correct.
A package of environment
- Windows 7 64-bit flagship edition
- 32-bit Python3.8.6
- 32-bit pywin32 library
- pyinstaller4.1
- Pandas, XLRD, XLWT… (This is the library I use in my development, not related to packaging)
Ii Packaging Process
- Download the 32-bit python3.x, 32-bit PyWin32, pyInstaller file ahead of time
- Install 32-bit PYTHon3.x
- Install the 32-bit pyWin32 to 32-bit python3.x directory, then run CMD to enter the directory and execute
python3 ./Scripts/pywin32_postinstall.py -install
- Decompress the PyInstaller to the 32-bit python3.x directory and run the CMD command to the PyInstaller folder
python setup.py install
The command - Place the function code files in the PyInstaller folder
- Install the libraries that depend on the functionality code one by one, and execute
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn module_name
, module_name is the library name - Package: Run the command
python32 pyinstaller.py -F xx.py
Three Points for attention
- If the 64-bit Python version is available on the PC, you are advised to rename the 32-bit python.exe, for example, python32.exe, and use python32 to specify the Python version in subsequent commands
- Basic Windows instruction, enter folder instruction (absolute path)
:d/python32/pyinstaller/
- After the PyInstaller is decompressed, a folder with the same name is nested and needs to be deleted
- If your computer does not have Python, you will be prompted to upgrade
pip
Version, follow the instructions prompted (similarpip install --upgrade pip
Command, no screenshots, later added) - Adopt traditional
pip install xxxx
The speed is very slow, so it is recommended to use the domestic mirror. Strictly follow step 6 above - The requirement. TXT dependency library was exported by me on Mac, but according to the name, it is not applicable in Win32 environment, so it needs to be manually installed (Windows virtual environment is not studied, will be added later).
- If an error occurs
ERROR:Cannot unpack file xxxx
, is caused by download failure, domestic mirror can be used to solve, instructions strictly follow step 6 above - The more common options for installation instructions are:
-w
: Remove command line window;-n xxxx
Specify a name (a folder with the same name will be created in the PyInstaller directory, and the exe file will be in the dist folder in this folder. The default is the script name);
The four resources
- Win32 packing buckets (that is, 32-bit Python3.8.6, 32-bit pywin32, pyinstaller4.1, download speed faster) : link: pan.baidu.com/s/1w5pimYfO… Extraction code: yexy
- GitHub address: github.com/LuckyStrike…
The resources
Pythoninstaller installer installer installer installer installer installer installer installer installer installer installer installer installer installer installer ERROR:Cannot unpack file XXXX The Python script generates a single EXE file