Pyinstaller打包遇到的问题

1. 运行exe文件 提示 failed to execute script main

    Debug后查找错误原因是 ModuleNotFoundError: No module named 'distutils'

   【解决办法】

    降级virtualenv的版本为 16.1,重新建立虚拟环境并下载所需包

   【参考

    https://blog.csdn.net/qq_33196814/article/details/88565441

2. 运行exe文件 提示 failed to execute script main

    Debug后查找错误原因是 ModuleNotFoundError: No module named 'win32com'

   【解决办法】

    pip install pywin32

3. (未解决)在win7平台打包时使用upx工具压缩,在win10平台运行报错,未压缩时运行正常。

4. 虚拟环境中打包PyQt5运行报错,打包前运行正常;本地环境打包前后均运行正常

   

  【解决办法】

    未找到Qt platform plugin的具体位置,在代码中添加

dirname = 'D:softPython36Libsite-packagesPyQt5Qt' #本地环境中所安装包的绝对路径
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

5. 运行exe文件 提示  failed to execute script pyi_rth_pkgres

   【解决办法】

      pyinstaller --hidden-import=pkg_resources.py2_warn XXXX.py

    参考 https://stackoverflow.com/questions/37815371/pyinstaller-failed-to-execute-script-pyi-rth-pkgres-and-missing-packages

原文地址:https://www.cnblogs.com/rn-05181226-rw/p/11535721.html