Python Forum
PIL ImageTk issue with MATPLOTLIB
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PIL ImageTk issue with MATPLOTLIB
#1
I am trying to run my program on a Linux unit, knowing that the code works on OSx and Windows.

I keep encountering the same issue, which relates to PIL and the ImageTk.py file - it doesn't exist.

I am getting the following error message:

Error:
Traceback (most recent call last): File "/home/gn95/Documents/15.01.2023/main.py", line 4, in <module> from GraphCreate import * File "/home/gn95/Documents/15.01.2023/GraphCreate.py", line 7, in <module> from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg File "/home/gn95/.local/lib/python3.9/site-packages/matplotlib/backends/backend_tkagg.py", line 1, in <module> from . import _backend_tk File "/home/gn95/.local/lib/python3.9/site-packages/matplotlib/backends/_backend_tk.py", line 14, in <module> from PIL import Image, ImageTk ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib64/python3.9/site-packages/PIL/__init__.py)
I have tried sudo apt-get install python3-pil python3-pil.imagetk and got...

Output:
Reading package lists... Done Building dependency tree... Done E: Unable to locate package python3-pil E: Unable to locate package python3-pil.imagetk E: Couldn't find any package by glob 'python3-pil.imagetk' E: Couldn't find any package by regex 'python3-pil.imagetk'
I have upgraded matplotlib, python, pip, tkinter and customtkinter (all the tools I am using).

I have gone to the location defined by the error message and there is certainly no ImageTk.py (or similar).

I have checked the comments online but all the fixes using apt-get result in no package found, whilst PIP only is happy with the installs I know already work.

I'm struggling to know where to look now; or what to do.
This is a work computer and not a personal one. I have SUDO access and am running Fedora 5.17.12-100.fc34.x86_64. I am running pip 22.3.1 and Python 3.9.13. Matplot is 3.6.3.

Since it is Fedora I have replaced apt-get with dnf, to no avail.

Any ideas?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ImageTk Paste KDog 14 6,910 Jun-27-2021, 11:07 AM
Last Post: KDog
  blank graph with matplotlib from a csv file / data type issue arsentievalex 0 1,951 Apr-06-2021, 10:08 AM
Last Post: arsentievalex
  Matplotlib: How do I convert Dates from Excel to use in Matplotlib JaneTan 1 3,230 Mar-11-2021, 10:52 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020