当我使用pyinstaller冻结带有pyside2的应用程序时为什么会出错?

时间:2019-07-11 16:30:27

标签: python pyinstaller pyside2

在我使用Pyside2编写python脚本之后,我使用PyInstaller冻结了我的应用程序,但是我却遇到了

Cannot find existing PyQt5 plugin directories

但是我没有使用PyQt5。我在main.py中导入的所有模块都是

import sys
import os
import PySide2
import vtk
from PySide2.QtWidgets import QMainWindow, QPushButton, QFrame, QVBoxLayout, QHBoxLayout, QFileDialog, QApplication, QMessageBox, QLineEdit, QLabel, QSlider, QTextBrowser, QWidget
from PySide2.QtCore import Slot, QDir, Qt
from vtk.qt4.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from vtk.util import numpy_support
from vesselfit import get_vessel
import SimpleITK as sitk
import cv2 as cv
import numpy as np
from copy import deepcopy
from classification import ImageClassifier

并在我的category.py中,导入以下内容:

import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import torch.nn.functional as F
import tensorboardX
import errno
from PIL import Image
import soundfile as sf
import json
import logging

错误日志是

69 INFO: PyInstaller: 3.4
70 INFO: Python: 3.6.4
71 INFO: Platform: Windows-10-10.0.17763-SP0
76 INFO: wrote C:\Users\klyjm\PycharmProjects\untitled1\test.spec
83 INFO: UPX is not available.
83 INFO: Extending PYTHONPATH with paths
['C:\\Users\\klyjm\\PycharmProjects\\untitled1',
 'C:\\Users\\klyjm\\PycharmProjects\\untitled1']
84 INFO: checking Analysis
84 INFO: Building Analysis because Analysis-00.toc is non existent
85 INFO: Initializing module dependency graph...
88 INFO: Initializing module graph hooks...
90 INFO: Analyzing base_library.zip ...
3059 INFO: running Analysis Analysis-00.toc
3075 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\ProgramData\Anaconda3\envs\vessel\python.exe
3330 INFO: Caching module hooks...
3334 INFO: Analyzing C:\Users\klyjm\PycharmProjects\untitled1\main.py
4623 INFO: Processing pre-find module path hook   distutils
5466 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
5858 INFO: Processing pre-find module path hook   site
5859 INFO: site: retargeting to fake-dir 'C:\\ProgramData\\Anaconda3\\envs\\vessel\\lib\\site-packages\\PyInstaller\\fake-modules'
9770 INFO: Processing pre-safe import module hook   six.moves
15894 INFO: Loading module hooks...
15895 INFO: Loading module hook "hook-cv2.py"...
15897 INFO: Loading module hook "hook-distutils.py"...
15898 INFO: Loading module hook "hook-encodings.py"...
15984 INFO: Loading module hook "hook-lib2to3.py"...
15987 INFO: Loading module hook "hook-matplotlib.backends.py"...
16560 INFO:   Matplotlib backend "GTK3Agg": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
16887 INFO:   Matplotlib backend "GTK3Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
17289 INFO:   Matplotlib backend "MacOSX": ignored
    cannot import name '_macosx'
17592 INFO:   Matplotlib backend "nbAgg": ignored
    No module named 'IPython'
18080 INFO:   Matplotlib backend "Qt4Agg": added
18385 INFO:   Matplotlib backend "Qt4Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
18892 INFO:   Matplotlib backend "Qt5Agg": added
19191 INFO:   Matplotlib backend "Qt5Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
19623 INFO:   Matplotlib backend "TkAgg": added
20043 INFO:   Matplotlib backend "TkCairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
20631 INFO:   Matplotlib backend "WebAgg": added
21045 INFO:   Matplotlib backend "WX": ignored
    No module named 'wx'
21348 INFO:   Matplotlib backend "WXAgg": ignored
    No module named 'wx'
21655 INFO:   Matplotlib backend "WXCairo": ignored
    No module named 'wx'
21967 INFO:   Matplotlib backend "agg": added
22278 INFO:   Matplotlib backend "cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
22720 INFO:   Matplotlib backend "pdf": added
23138 INFO:   Matplotlib backend "pgf": added
23451 INFO:   Matplotlib backend "ps": added
23765 INFO:   Matplotlib backend "svg": added
24168 INFO:   Matplotlib backend "template": added
24579 INFO: Loading module hook "hook-matplotlib.py"...
24861 INFO: Loading module hook "hook-numpy.core.py"...
24948 INFO: MKL libraries found when importing numpy. Adding MKL to binaries
24951 INFO: Loading module hook "hook-numpy.py"...
24952 INFO: Loading module hook "hook-PIL.Image.py"...
25276 INFO: Loading module hook "hook-PIL.py"...
25279 INFO: Import to be excluded not found: 'FixTk'
25280 INFO: Excluding import 'PySide'
25282 INFO:   Removing import of PySide from module PIL.ImageQt
25283 INFO: Excluding import 'tkinter'
25285 INFO:   Removing import of tkinter from module PIL.ImageTk
25286 INFO: Excluding import 'PyQt4'
25291 INFO: Excluding import 'PyQt5'
25295 INFO:   Removing import of PyQt5.QtCore from module PIL.ImageQt
25295 INFO:   Removing import of PyQt5.QtGui from module PIL.ImageQt
25297 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
25301 INFO: Import to be excluded not found: 'FixTk'
25301 INFO: Excluding import 'tkinter'
25304 INFO: Loading module hook "hook-pkg_resources.py"...
25602 INFO: Processing pre-safe import module hook   win32com
25819 INFO: Loading module hook "hook-pycparser.py"...
25820 INFO: Loading module hook "hook-pydoc.py"...
25821 INFO: Loading module hook "hook-PyQt5.py"...
25910 WARNING: Hidden import "PyQt5.sip" not found!
25911 INFO: Loading module hook "hook-PyQt5.QtCore.py"...
25972 WARNING: Unable to find Qt5 translations C:/qt64/qt_1544645195969/_h_env/Library/translations\qtbase_*.qm. These translations were not packaged.
25973 INFO: Loading module hook "hook-PyQt5.QtGui.py"...
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\vessel\Scripts\pyinstaller-script.py", line 10, in <module>
    sys.exit(run())
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
    exec(text, spec_namespace)
  File "<string>", line 17, in <module>
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\building\build_main.py", line 241, in __init__
    self.__postinit__()
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\building\build_main.py", line 500, in assemble
    module_hook.post_graph()
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\building\imphook.py", line 410, in post_graph
    self._load_hook_module()
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\building\imphook.py", line 377, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\compat.py", line 736, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 399, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 823, in load_module
  File "<frozen importlib._bootstrap_external>", line 682, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 684, in _load
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\hooks\hook-PyQt5.QtGui.py", line 11, in <module>
    hiddenimports, binaries, datas = add_qt5_dependencies(__file__)
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 514, in add_qt5_dependencies
    more_binaries = qt_plugins_binaries(plugin, namespace=namespace)
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 132, in qt_plugins_binaries
    pdir = qt_plugins_dir(namespace=namespace)
  File "C:\ProgramData\Anaconda3\envs\vessel\lib\site-packages\PyInstaller\utils\hooks\qt.py", line 117, in qt_plugins_dir
    """.format(namespace, ", ".join(paths)))
Exception:
            Cannot find existing PyQt5 plugin directories
            Paths checked: C:/qt64/qt_1544645195969/_h_env/Library/plugins

似乎是PIL引起的错误,我该如何解决?

0 个答案:

没有答案