首页 > 解决方案 > 使用“从 PyQt5 导入 uic”时,pyinstaller exe 冻结

问题描述

我正在尝试使用 python 启动 Adob​​e Photoshop 并在 Photoshop 中运行脚本。下面是我的代码。当我使用 python 3.9.1 从 windows 命令行运行时,它可以工作

如果我使用 pyinstaller 使用pyinstaller Photoshop.py. Photoshop 启动,脚本开始运行,然后进程冻结。

如果我在下面的代码中注释掉第二行,# from PyQt5 import uic然后再次运行 pyinstaller,生成的 .exe 没有问题并且运行起来就像我从命令行使用 python 运行它一样。

任何想法为什么从 PyQt5 导入 uic 会以某种方式弄乱 pyinstaller?

我意识到我正在导入 UIC 而不是使用它。此问题是使用该模块的较大项目的一部分。我刚刚在这里创建了一个小例子来帮助解决我的问题。

import subprocess
from PyQt5 import uic

class Photoshop2021:
    def __init__(self):
        print("Created")

    def runBenchmark(self):
        cmd = [r"C:\Program Files\Adobe\Adobe Photoshop 2021\Photoshop.exe",
               r"C:\Program Files\Adobe\Adobe Photoshop 2021\Presets\Scripts\TCL Photoshop Benchmark_AUTO 2.3.jsxbin"]

        subprocess.call(cmd, shell=True)

Photoshop2021().runBenchmark()

这是未注释导入语句并且 Photoshop 进程冻结时 pyinstaller 的输出。

C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp>pyinstaller --noconfirm PhotoshopTest.py
55 INFO: PyInstaller: 4.4
55 INFO: Python: 3.9.1
58 INFO: Platform: Windows-10-10.0.19041-SP0
61 INFO: wrote C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp\PhotoshopTest.spec
64 INFO: UPX is not available.
66 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Z8G4\\Desktop\\Automation-Sidekick\\build\\Temp',
 'C:\\Users\\Z8G4\\Desktop\\Automation-Sidekick\\build\\Temp']
73 INFO: checking Analysis
74 INFO: Building Analysis because Analysis-00.toc is non existent
74 INFO: Initializing module dependency graph...
79 INFO: Caching module graph hooks...
87 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
90 INFO: Analyzing base_library.zip ...
2083 INFO: Processing pre-find module path hook distutils from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
2084 INFO: distutils: retargeting to non-venv dir 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib'
3632 INFO: Caching module dependency graph...
3783 INFO: running Analysis Analysis-00.toc
3785 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\z8g4\appdata\local\programs\python\python39\python.exe
3840 WARNING: lib not found: api-ms-win-core-path-l1-1-0.dll dependency of c:\users\z8g4\appdata\local\programs\python\python39\python39.dll
3857 INFO: Analyzing C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp\PhotoshopTest.py
3925 INFO: Processing pre-find module path hook PyQt5.uic.port_v2 from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-PyQt5.uic.port_v2.py'.
3989 INFO: Processing module hooks...
3990 INFO: Loading module hook 'hook-difflib.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3993 INFO: Loading module hook 'hook-distutils.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3995 INFO: Loading module hook 'hook-distutils.util.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
3996 INFO: Loading module hook 'hook-encodings.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4075 INFO: Loading module hook 'hook-heapq.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4076 INFO: Loading module hook 'hook-lib2to3.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4110 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4111 INFO: Loading module hook 'hook-pickle.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4113 INFO: Loading module hook 'hook-PyQt5.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4268 WARNING: Hidden import "sip" not found!
4269 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4332 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4457 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4719 INFO: Loading module hook 'hook-PyQt5.uic.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4723 INFO: Loading module hook 'hook-sysconfig.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4724 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4725 INFO: Loading module hook 'hook-xml.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4764 INFO: Loading module hook 'hook-_tkinter.py' from 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks'...
4872 INFO: checking Tree
4872 INFO: Building Tree because Tree-00.toc is non existent
4874 INFO: Building Tree Tree-00.toc
4924 INFO: checking Tree
4925 INFO: Building Tree because Tree-01.toc is non existent
4926 INFO: Building Tree Tree-01.toc
4996 INFO: checking Tree
4997 INFO: Building Tree because Tree-02.toc is non existent
4999 INFO: Building Tree Tree-02.toc
5019 INFO: Looking for ctypes DLLs
5033 INFO: Analyzing run-time hooks ...
5035 INFO: Including run-time hook 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
5037 INFO: Including run-time hook 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
5044 INFO: Including run-time hook 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
5045 INFO: Including run-time hook 'c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyqt5.py'
5052 INFO: Looking for dynamic libraries
5938 INFO: Looking for eggs
5938 INFO: Using Python library c:\users\z8g4\appdata\local\programs\python\python39\python39.dll
5940 INFO: Found binding redirects:
[]
5946 INFO: Warnings written to C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp\build\PhotoshopTest\warn-PhotoshopTest.txt
5983 INFO: Graph cross-reference written to C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp\build\PhotoshopTest\xref-PhotoshopTest.html
5994 INFO: checking PYZ
5994 INFO: Building PYZ because PYZ-00.toc is non existent
5995 INFO: Building PYZ (ZlibArchive) C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp\build\PhotoshopTest\PYZ-00.pyz
6449 INFO: Building PYZ (ZlibArchive) C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp\build\PhotoshopTest\PYZ-00.pyz completed successfully.
6460 INFO: checking PKG
6460 INFO: Building PKG because PKG-00.toc is non existent
6461 INFO: Building PKG (CArchive) PKG-00.pkg
6478 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
6479 INFO: Bootloader c:\users\z8g4\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
6479 INFO: checking EXE
6480 INFO: Building EXE because EXE-00.toc is non existent
6483 INFO: Building EXE from EXE-00.toc
6485 INFO: Copying icons from ['c:\\users\\z8g4\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
6486 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
6486 INFO: Writing RT_ICON 1 resource with 3752 bytes
6487 INFO: Writing RT_ICON 2 resource with 2216 bytes
6487 INFO: Writing RT_ICON 3 resource with 1384 bytes
6490 INFO: Writing RT_ICON 4 resource with 37019 bytes
6491 INFO: Writing RT_ICON 5 resource with 9640 bytes
6495 INFO: Writing RT_ICON 6 resource with 4264 bytes
6498 INFO: Writing RT_ICON 7 resource with 1128 bytes
6501 INFO: Appending archive to EXE C:\Users\Z8G4\Desktop\Automation-Sidekick\build\Temp\build\PhotoshopTest\PhotoshopTest.exe
6830 INFO: Building EXE from EXE-00.toc completed successfully.
6833 INFO: checking COLLECT
6833 INFO: Building COLLECT because COLLECT-00.toc is non existent
6835 INFO: Building COLLECT COLLECT-00.toc
7267 INFO: Building COLLECT COLLECT-00.toc completed successfully.

标签: pythonpyqt5pyinstallerphotoshop

解决方案


推荐阅读