Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message: #1

Open
barpi opened this issue Mar 29, 2024 · 1 comment
Open

Error message: #1

barpi opened this issue Mar 29, 2024 · 1 comment

Comments

@barpi
Copy link

barpi commented Mar 29, 2024

python /home/.../Videók/AudioVideoFlipper_Imagination_Gym-main/start_flipper_ui.py
Traceback (most recent call last):
File "/home/arpad/Videók/AudioVideoFlipper_Imagination_Gym-main/start_flipper_ui.py", line 6, in
from av_flipper import AudioVideoFlipper, ConfigLoader, FlipperScriptArgs
File "/home/arpad/Videók/AudioVideoFlipper_Imagination_Gym-main/av_flipper.py", line 9, in
from PIL import Image, ImageTk
ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/init.py)

@keithorange
Copy link
Owner

keithorange commented Mar 31, 2024

Never saw that before! Make sure you have the LATEST python, 3.12 (or 3.11)!

Python 3.12.0 (v3.12.0:0fb18b02c8, Oct  2 2023, 09:45:56) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image, ImageTk
>>>

Remeber to run

pip3 install Pillow

otherwise I asked ChatGPT:

I understand your question now. The confusion likely arises from the history of PIL (Python Imaging Library) and its successor, Pillow. To clarify, PIL is the original Python Imaging Library, which is no longer maintained. Pillow was forked from PIL to support ongoing development. When working with modern Python code, you should use Pillow, not PIL, as it is the actively maintained project and is compatible with PIL.

Regarding ImageTk, it is a part of Pillow that allows PIL images to be displayed in Tkinter applications. There isn't a separate pip package named pil or tk-pil that you should install. Instead, you ensure Pillow is installed (which provides the PIL namespace) and then ensure that your system has the necessary Tkinter support for Pillow's ImageTk functionality.

The correct way to install Pillow, which includes support for Image, is using pip:

pip install Pillow

However, for ImageTk to work, you also need Tkinter installed. Tkinter is typically included with Python, but on some systems, especially Linux distributions, you might need to install it separately. On Debian-based systems like Ubuntu, you can ensure Tkinter is installed with:

sudo apt-get install python3-tk

After that, if you still encounter issues with ImageTk, it's often due to missing system-level packages that Pillow relies on for this functionality. On Debian/Ubuntu, you can ensure these are installed with:

sudo apt-get install python3-pil.imagetk

This command installs the Tkinter components for Pillow (PIL) at the system level, which Pillow should then be able to use.

So, in summary:

  1. Use pip install Pillow to install Pillow (which supersedes PIL).
  2. Ensure Tkinter is installed, which is usually included with Python but may require separate installation on Linux.
  3. On some systems, you might need additional packages like python3-pil.imagetk for ImageTk support.

If following these steps doesn't resolve the issue, it might be helpful to check the documentation for Pillow and your system's package manager to ensure all dependencies are correctly installed.

Let me know the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants