AttributeError:模块“ PIL.ImageQt”没有属性“ ImageQt”

问题描述

import sys
import pickle as p
from PyQt4 import QtCore,QtGui,uic
import numpy as n
import PIL.ImageQt as PQ
from PIL import Image
import cv2
import os

self.currentFrame=cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
self.currentSeg=Image.fromarray(thresh).convert('RGB')
self.currentSeg = PQ.ImageQt(self.currentSeg)
height,width=self.currentFrame.shape[:2]

出现以上错误提示imageQt没有属性。香港专业教育学院试图改变from PIL.ImageQt import ImageQt,但它给ImportError: cannot import name 'ImageQt' from 'PIL.ImageQt'

解决方法

您似乎确实在混入进口商品。似乎很详细

import PIL.ImageQt as PQ

发生冲突
self.currentSeg = PQ.ImageQt(self.currentSeg)

如果ImageQt是您要访问的对象,那么我建议按照以下步骤更改行:

import PIL.ImageQt as PQ
self.currentSeg = PQ(self.currentSeg)