Skip to content

ImportError: cannot import name 'ImageTk' from 'PIL' #181

@su542sa

Description

@su542sa

Hi,
I am following this tutorial for running YOLO v8 to detect and automatically identify number plates from a video. I am currently on, 30:02 time in the video, where he runs the code successfully. However, my code brings the following error:
Traceback (most recent call last): File "/home/pi/yolotest.py", line 3, in <module> from sort.sort import * File "/home/pi/sort/sort.py", line 23, in <module> matplotlib.use('TkAgg') File "/home/pi/env/lib/python3.11/site-packages/matplotlib/__init__.py", line 1255, in use plt.switch_backend(name) File "/home/pi/env/lib/python3.11/site-packages/matplotlib/pyplot.py", line 415, in switch_backend module = backend_registry.load_backend_module(newbackend) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/env/lib/python3.11/site-packages/matplotlib/backends/registry.py", line 323, in load_backend_module return importlib.import_module(module_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/pi/env/lib/python3.11/site-packages/matplotlib/backends/backend_tkagg.py", line 1, in <module> from . import _backend_tk File "/home/pi/env/lib/python3.11/site-packages/matplotlib/backends/_backend_tk.py", line 16, in <module> from PIL import Image, ImageTk ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)

Note that I am using a Raspberry Pi 5 4 GB RAM running Raspberry Pi OS 64-bit. Along with that, all the system packages and libraries(including sort folder downloaded) are in a python virtual environment. Please help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions