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.

strace python -c 'from PIL.ImageQt import ImageQt'

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:

apt install -y libegl1 libgl1 libxkbcommon0
Answer from Dodgyrabbit on Stack Overflow
🌐
GitHub
github.com › python-pillow › Pillow › issues › 1557
ImageQt missing import · Issue #1557 · python-pillow/Pillow
November 27, 2015 - $ python -c "from PIL import ImageQt; from PyQt4.QtGui import QImage; qim = QImage(32, 32, QImage.Format_ARGB32); im = ImageQt.fromqimage(qim)" Traceback (most recent call last): File "<string>", line 1, in <module> File "PIL/ImageQt.py", line 72, in fromqimage return PIL.Image.open(b) AttributeError: 'module' object has no attribute 'Image' No one assigned ·
Published   Nov 27, 2015
Discussions

image - how to use ImageQt - Stack Overflow
I would like to use ImageQT so I can do image manipulation with the Python Image Library (PIL) and render the result using Qt4. I have a short test routine that reads the using PIL.Image.open, con... More on stackoverflow.com
🌐 stackoverflow.com
import - Python PIL has no attribute 'Image' - Stack Overflow
I'm using python2.6 and got a problem this morning. It said 'module' has no attribute 'Image'. Here is my input. Why the first time I can not use PIL.Image? >>> import PIL >>> PIL. More on stackoverflow.com
🌐 stackoverflow.com
Loading PIL Image to QPixMap
I have a need to get PSD photos into a QLabel from PyQt5. PIL.ImageQt would appear to be the tool. I keep getting errors like 'module' object is not callable. relevant code from PIL import ... More on github.com
🌐 github.com
2
1
AttributeError: module 'PIL' has no attribute 'Image' - UTC+5 India - fast.ai Course Forums
Hello everyone, i just started going through lesson-1 in google-colab. As i was going through line by line along with the lecture video i was stuck when i came to these lines of code data = ImageDataBunch.from_name_re(… More on forums.fast.ai
🌐 forums.fast.ai
0
January 28, 2019
🌐
GitHub
github.com › python-pillow › Pillow › issues › 5266
ImageQt does not work as expected in PyQt5 · Issue #5266 · python-pillow/Pillow
February 13, 2021 - Note: The same code works in PySide6, but not in PyQt5. ... import sys from PIL import Image, ImageQt from PyQt5.QtGui import QPixmap, QImage from PyQt5.QtWidgets import QWidget, QLabel from PyQt5.QtWidgets import QVBoxLayout, QApplication class ImageViewer(QWidget): def __init__(self): QWidget.__init__(self) self.setWindowTitle("PyQt Image Viewer") # Open up image in Pillow image = Image.open("pink_flower.jpg") qt_image = ImageQt.ImageQt(image) pixmap = QPixmap.fromImage(qt_image) self.image_label = QLabel('') self.image_label.setPixmap(pixmap) self.main_layout = QVBoxLayout() self.main_layout.addWidget(self.image_label) self.setLayout(self.main_layout) if __name__ == "__main__": app = QApplication(sys.argv) viewer = ImageViewer() viewer.show() app.exec_()
Author   driscollis
🌐
Pillow Documentation
pillow.readthedocs.io › en › stable › reference › ImageQt.html
ImageQt module - Pillow (PIL Fork) 12.1.1 documentation
The ImageQt module contains support for creating PyQt6 or PySide6 QImage objects from PIL images.
🌐
The Mail Archive
mail-archive.com › debian-bugs-dist@lists.debian.org › msg1917323.html
Bug#1042173: openlp: FTBFS: AttributeError: module 'PIL.ImageQt' has no attribute 'ImageQt'
July 26, 2023 - > [100%] > > =================...ore/api/tab.py", > line 291, in set_urls > img = PIL.ImageQt.ImageQt(img) > ^^^^^^^^^^^^^^^^^^^ > AttributeError: module 'PIL.ImageQt' has no attribute 'ImageQt' > ________________________________________________________________________________ ...
🌐
GitHub
github.com › python-pillow › Pillow › blob › main › src › PIL › ImageQt.py
Pillow/src/PIL/ImageQt.py at main · python-pillow/Pillow
:param im: QImage or PIL ImageQt object · """ buffer = QBuffer() qt_openmode: object · if qt_version == "6": try: qt_openmode = getattr(QIODevice, "OpenModeFlag") except AttributeError: qt_openmode = getattr(QIODevice, "OpenMode") else: qt_openmode = QIODevice ·
Author   python-pillow
🌐
CopyProgramming
copyprogramming.com › howto › module-pil-has-no-attribute-fromarray
Python: AttributeError: 'module' object has no attribute 'fromarray' in pil
March 31, 2023 - AttributeError: module 'PIL.ImageQt' has no attribute, It looks you are indeed messing with imports. In detail it seems. import PIL.ImageQt as PQ. is in conflict with.
Find elsewhere
🌐
Fast.ai
forums.fast.ai › part 1 (2019) › utc+5 india
AttributeError: module 'PIL' has no attribute 'Image' - UTC+5 India - fast.ai Course Forums
January 28, 2019 - Hello everyone, i just started going through lesson-1 in google-colab. As i was going through line by line along with the lecture video i was stuck when i came to these lines of code data = ImageDataBunch.from_name_re(path_img, fnames, pat, ds_tfms=get_transforms(), size=224, bs=bs) data.normalize(imagenet_stats) when i ran above lines i got the following error: AttributeError: module ‘PIL.Image’ has no attribute ‘register_extensions please, somebody help me, i got stuck at this point tha...
🌐
Reddit
reddit.com › r/learnpython › pil has no attribute: image
r/learnpython on Reddit: PIL has no attribute: Image
September 30, 2021 -

Hey, everyone!
I'm trying to execute this notebook, but I came across an attribute error: PIL has no attribute Image.

I tried implementing "from PIL import Image" , and other common fixes available on StackOverflow, but I didn't get anywhere. I want to be able to plot the images. And not using matplotlib. Is there any workaround to this?

🌐
Virtualplants
virtualplants.github.io › _modules › image › pil › ImageQt.html
image.pil.ImageQt — OpenAlea community website
# # @param im A PIL Image object, or a file name (given either as Python # string or a PyQt string object). [docs]class ImageQt(QImage): def __init__(self, im): data = None colortable = None # handle filename, if given instead of image name if hasattr(im, "toUtf8"): # FIXME - is this really the best way to do this?
🌐
Fast.ai
forums.fast.ai › part 1 (2018) › beginner (2018)
I am getting AttributeError: module 'PIL' has no attribute 'Image' - Beginner (2018) - fast.ai Course Forums
April 23, 2018 - While on lesson 1 on code line - plot_val_with_title(rand_by_correct(True), “Correctly classified”) i am getting the error - module ‘PIL’ has no attribute ‘Image’. I cant move forward with it , can someone please help me…
🌐
Readthedocs
pillow-wiredfool.readthedocs.io › en › latest › reference › ImageQt.html
ImageQt Module — Pillow v2.4.0 (PIL fork)
Creates an ImageQt object from a PIL Image object. This class is a subclass of QtGui.QImage, which means that you can pass the resulting objects directly to PyQt4/5 API functions and methods. This operation is currently supported for mode 1, L, P, RGB, and RGBA images.
🌐
GitHub
github.com › OpenTTD › nml › issues › 39
(AttributeError) "module 'PIL.Image' has no attribute 'VERSION'". · Issue #39 · OpenTTD/nml
June 3, 2019 - I am working on a Windows 64 bit laptop with Conda v2019.03, running a Python 3.6.0 environment. After installing all the dependencies, when I try to run nmlc -h it shows me the following error: nmlc ERROR: nmlc: An internal error has occurred: nmlc-version: 0.4.5 Error: (AttributeError) "module 'PIL.Image' has no attribute 'VERSION'".
Author   oss-vineet
🌐
Fast.ai
forums.fast.ai › part 1 (2018)
AttributeError: module ‘PIL.Image’ has no attribute ‘register_extensions - Part 1 (2018) - fast.ai Course Forums
January 31, 2018 - I had similar issue. Next time, you start your colab VM, be sure to comment out the following two lines (i.e do not run them) · I also spent the few hours searching, for the cause. I think now that I have found the issue. There is actually no function with the name register_extensions() but ...
🌐
Reddit
reddit.com › r/learnprogramming › "module 'pil.image' has no attribute 'show'", but pil is working as expected.
r/learnprogramming on Reddit: "module 'PIL.Image' has no attribute 'show'", but PIL is working as expected.
January 16, 2024 -

SOLVED: Turns out BYU wrote a library specifically for the course which replaces PIL's Image, despite them giving explicit instructions to use PIL. Disregard if not specifically working on project one of CS111 at BYU. If you happen to be doing so, go look at the slides for lecture 7. You will need to import the byuimage library, which is not included in any of the distribution code, even though PIL imports are.

Hey guys! I'm working on some projects necessary to get a class waived at the school I'll (pending aceptance) be going to next fall. My experience with python is, well, very little, but the intro class uses python so I'm doing the work in Python.

The first project entails a simple "image processing" program. I've got to the first point to run a pytest (I have zero prior experience with pytest, so if I've done something done there, my bad), which is just to open and display the passed image. Program works as intended, but when I run the pytest written by the school, I get the following error.

__test_display_image ______________________________
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x0000024D0468D2D0>
@max_score(20)
def test_display_image(monkeypatch):
    observed = None
  @functools.wraps(Image.show)
E       AttributeError: module 'PIL.Image' has no attribute 'show'
test_project1.py:23: AttributeError

At first, I assumed that Pillow wasn't getting imported correctly, but the import line is the same in teh pytest as in the program.

from PIL import Image

After a good deal of googling, I've found similar looking errors dealing with other methods of Image, but none concerning .show, and they all have wildly different reasons, so I'm at a bit of a loss. The pytest and program files are in the same directory. I'm sure it's something dumb, but I'm not really sure what else to look at, so I'd love to have my dumb mistake pointed out! Thank you all!

Pytest code

from PIL import Image
from byu_pytest_utils import max_score, run_python_script, test_files
import functools import pytest

def assert_equal(observed: Image, expected: Image):
    assert observed.width == expected.width assert observed.height ==             
expected.height for y in range(observed.height):
        for x in range(observed.width): 
            observed_pixel = observed.get_pixel(x, y) expected_pixel =                     
        expected.get_pixel(x, y)
            assert observed_pixel.red == expected_pixel.red, f"the pixels at 
        ({x}, {y}) don't match" 
            assert observed_pixel.green == expected_pixel.green, f"the pixels at                 
         ({x}, {y}) don't match" 
            assert observed_pixel.blue == expected_pixel.blue, f"the pixels at                 
        ({x}, {y}) don't match"

@max_score(20) def test_display_image(monkeypatch):
    observed = None @functools.wraps(Image.show) 

    def patched_Image_show(self):
        nonlocal observed
        observed = self 
        monkeypatch.setattr(Image, 'show', patched_Image_show)

        run_python_script('image_processing.py', '-d',
                  test_files / 'explosion.input.png')

        if observed is None:
            pytest.fail('No Image was shown')

        assert_equal(observed, Image(test_files / 'explosion.input.png'))

Program code (though I don't think it should matter)

import sys
from PIL import Image

def main():
if not validate_command(sys.argv):
    return

run_command()

def validate_command(args):
    try: 
        if args[1][0:1] == '-' and args[2] != None:
            print(f"Running image processor with aruments {args[1]}, {args[2]}")         
            return True
        else:
        print("Invlaid arguments. Usage: image_processing.py <operation>     
         [<argument 1> <argument 2> ...]") 
    except: print("Invlaid arguments. Usage: image_processing.py <operation> 
        [<argument 1> <argument 2> ...]")
            return False

def display(image):
    image.show()

def run_command():
image = Image.open(sys.argv[2])
commands[sys.argv[1]](image)

commands = {"-d": display}

main()

(Pasting into reddit messed up the formatting, so it's possible I made a mistake when correcting the formatting)

Top answer
1 of 2
2

This is a known versioning issue between cinnamon and pillow >= 6.0.0. You can find more info here. As a previous commenter said, you can find the error in /usr/share/cinnamon/cinnamon-settings/bin/imtools.py. However, changing Image.VERSION to PIL.VERSION will not fix the issue for pillow >= 7.0.0. You must instead change the line to if Image.__version__ == '1.1.7':.

2 of 2
1

If you are comfortable with python. You can modify /usr/share/cinnamon/cinnamon-settings/bin/imtools.py.

  1. Make a backup of the file. i.e
sudo cp /usr/share/cinnamon/cinnamon-settings/bin/imtools.py /usr/share/cinnamon/cinnamon-settings/bin/imtools.py.bk
  1. Open /usr/share/cinnamon/cinnamon-settings/bin/imtools.py with nano
sudo nano /usr/share/cinnamon/cinnamon-settings/bin/imtools.py
  1. Delete line 623 to 636. And shift lines 637 to 645 4 spaces to the left.

Before:

if Image.VERSION == '1.1.7':

    def split(image):
        """Work around for bug in Pil 1.1.7

        :param image: input image
        :type image: PIL image object
        :returns: the different color bands of the image (eg R, G, B)
        :rtype: tuple
        """
        image.load()
        return image.split()
else:

    def split(image):
        """Work around for bug in Pil 1.1.7

        :param image: input image
        :type image: PIL image object
        :returns: the different color bands of the image (eg R, G, B)
        :rtype: tuple
        """
        return image.split()

After:

def split(image):
    """Work around for bug in Pil 1.1.7

    :param image: input image
    :type image: PIL image object
    :returns: the different color bands of the image (eg R, G, B)
    :rtype: tuple
    """
    return image.split()

A check for version Image.VERSION 1.1.7 is not needed if you are using current version of PIL.