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

  1. Download the 32-bit python3.x, 32-bit PyWin32, pyInstaller file ahead of time
  2. Install 32-bit PYTHon3.x
  3. Install the 32-bit pyWin32 to 32-bit python3.x directory, then run CMD to enter the directory and executepython3 ./Scripts/pywin32_postinstall.py -install
  4. Decompress the PyInstaller to the 32-bit python3.x directory and run the CMD command to the PyInstaller folderpython setup.py installThe command
  5. Place the function code files in the PyInstaller folder
  6. Install the libraries that depend on the functionality code one by one, and executepip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn module_name , module_name is the library name
  7. Package: Run the commandpython32 pyinstaller.py -F xx.py

Three Points for attention

  1. 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
  2. Basic Windows instruction, enter folder instruction (absolute path):d/python32/pyinstaller/
  3. After the PyInstaller is decompressed, a folder with the same name is nested and needs to be deleted
  4. If your computer does not have Python, you will be prompted to upgradepipVersion, follow the instructions prompted (similarpip install --upgrade pipCommand, no screenshots, later added)
  5. Adopt traditionalpip install xxxxThe speed is very slow, so it is recommended to use the domestic mirror. Strictly follow step 6 above
  6. 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).
  7. If an error occursERROR:Cannot unpack file xxxx, is caused by download failure, domestic mirror can be used to solve, instructions strictly follow step 6 above
  8. The more common options for installation instructions are:-w: Remove command line window;-n xxxxSpecify 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