Skip to content

ImportError: Cannot Import ‘_imagingft’ from PIL in communication_handler.py #19

@Lib3Ns

Description

@Lib3Ns

Which installation method have you chosen?

Python Virtual Environment (venv)

What version of the software are you using?

Pillow 9.5.0

What operating system are you using (Name and Version)?

Linux Ubuntu 24.04

What browser are you using (Name and Version)?

No response

Describe your issue

Good morning,
while processing the products retrieved via the Amazon APIs, I encountered this issue related to the version of Pillow/PIL:

2025-05-18 17:30:45 :: [communication_handler.py ] - [single_message         ] - [ERROR   ] - 1 - An error occurred while extracting the message information from the product for the asin B0CPLWSGFP: cannot import name '_imagingft' from 'PIL' (/var/www/python/TelegramBot-AmazonOffers/.venv/lib/python3.12/site-packages/PIL/__init__.py)

I tried installing the latest version of Pillow, and the issue is resolved, but then the following command no longer works:

  w1, h1 = draw.textsize(f"{old_price}{old_currency}", font=font1)
  w2, h2 = draw.textsize(f"{new_price}{currency}", font=font2)

So, when updating the function draw.textsize to draw.textlength, it raises the following exception:

cannot unpack non-iterable float object

How can I resolve this?

Thank you.

Describe the steps to reproduce the issue

Run python src/main.py
Wait for the Amazon API product processing.

To speed up the resolution of the issue, please provide the logs file.

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions