Python 打包 windows 可執行的 exe 檔案

初識不知君發表於2020-11-23

需要安裝 pyinstall 即可打包成 windows 可執行的 exe 檔案

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple PyInstaller

我在安裝時出現了下面的錯誤:

Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9e/ed/fbdad7f5d8f794c901076b814b8e9f5ce31d32c0bc3b63ddd27b61db9530/pyinstaller-4.1.tar.gz (3.5 MB)
     |████████████████████████████████| 3.5 MB 1.6 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'D:\Program Files\python3.8\python.exe' 'D:\Program Files\python3.8\lib\site-packages\pip-20.2.4-py3.8.egg\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\迅幫網~1\AppData\Local\Temp\tmp5r4t5sif'
         cwd: C:\Users\auth\AppData\Local\Temp\pip-install-c0xpvew0\pyinstaller
    Complete output (38 lines):
    running dist_info
    creating C:\Users\auth\AppData\Local\Temp\pip-modern-metadata-nesedid2\pyinstaller.egg-info

解決辦法:
先安裝 wheel,之後再安裝 pyinstaller 就可以了

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple wheel

直接執行

pyinstaller -F 檔案路徑.py

相關文章