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]
im getting above error that imageQt has no attribute. ive tried changing from PIL.ImageQt import ImageQt
but it gives ImportError: cannot import name 'ImageQt' from 'PIL.ImageQt'
Note that the error
ImportError: cannot import name 'ImageQt' from 'PIL.ImageQt'
can be quite misleading.If you look at the ImageQt.py source code, you'll see that the
ImageQt
class is only defined if it successfully detects one of the Qt libraries (pyside2/6, PyQt5/6).So you can get this error if you have a broken install of Qt. You may want to reinstall PySide6 or whatever you've been using.
You could also use a tool like
strace
and spy on the Python process (if you're using Linux) to see exactly what it's looking for.I used this technique to track down why this import was failing under Docker but working properly on a regular desktop.
For the (Ubuntu) Docker container to properly support the import statement, I had to also install these missing libraries: