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

ImportError: The _imagingft C module is not installed (Raspberry Pi 4 Buster) #5818

Closed
mightylastingcode opened this issue Nov 8, 2021 · 11 comments
Labels
Installation Usually a problem with … Linux

Comments

@mightylastingcode
Copy link

mightylastingcode commented Nov 8, 2021

I want to report this error. It has something to do with the latest version 8.4 of Pillow module. If I installed version 7.2, I would not get this error and the example (ssd1306_pillow_text.py) will work just fine with my OLED display.

Below is the complete track message. Again, it only happens when I run the example with version 8.4.

# /ssd1306_oled_display $ /home/pi/Documents/projects/python_examples/new_MyPiHat_v2/Adafruit_CircuitPython_projects/ssd1306_oled_display/venv/bin/python /home/pi/Documents/projects/python_examples/new_MyPiHat_v2/Adafruit_CircuitPython_projects/ssd1306_oled_display/ssd1306_pillow_text.py
# Traceback (most recent call last):
#   File "/home/pi/Documents/projects/python_examples/new_MyPiHat_v2/Adafruit_CircuitPython_projects/ssd1306_oled_display/ssd1306_pillow_text.py", line 36, in <module>
#     font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 28)
#   File "/home/pi/Documents/projects/python_examples/new_MyPiHat_v2/Adafruit_CircuitPython_projects/ssd1306_oled_display/venv/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype
#     return freetype(font)
#   File "/home/pi/Documents/projects/python_examples/new_MyPiHat_v2/Adafruit_CircuitPython_projects/ssd1306_oled_display/venv/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype
#     return FreeTypeFont(font, size, index, encoding, layout_engine)
#   File "/home/pi/Documents/projects/python_examples/new_MyPiHat_v2/Adafruit_CircuitPython_projects/ssd1306_oled_display/venv/lib/python3.9/site-packages/PIL/ImageFont.py", line 187, in __init__
#     if core.HAVE_RAQM:
#   File "/home/pi/Documents/projects/python_examples/new_MyPiHat_v2/Adafruit_CircuitPython_projects/ssd1306_oled_display/venv/lib/python3.9/site-packages/PIL/ImageFont.py", line 44, in __getattr__
#     raise ImportError("The _imagingft C module is not installed")
# ImportError: The _imagingft C module is not installed
@radarhere
Copy link
Member

I presume you're using pip to install Pillow?

As to why there is a difference, my first suspicion is that we are no longer providing binary wheels for your system - but let's check. Could you show the output of the pip command when you install Pillow 7.2?

As to fixing your problem, I recommend apt-get install libfreetype6-dev

@radarhere radarhere added the Linux label Nov 8, 2021
@mightylastingcode
Copy link
Author

mightylastingcode commented Nov 8, 2021 via email

@mightylastingcode
Copy link
Author

mightylastingcode commented Nov 8, 2021 via email

@mightylastingcode
Copy link
Author

mightylastingcode commented Nov 8, 2021 via email

@radarhere
Copy link
Member

So for 7.2.0 you downloaded https://www.piwheels.org/simple/pillow/Pillow-7.2.0-cp39-cp39-linux_armv7l.whl

And there is also https://www.piwheels.org/simple/pillow/Pillow-8.4.0-cp39-cp39-linux_armv7l.whl, so my initial theory was not correct.

Try building from source instead - pip3 install Pillow --no-binary :all:

@mightylastingcode
Copy link
Author

mightylastingcode commented Nov 8, 2021 via email

@radarhere
Copy link
Member

apt-get install libjpeg62-turbo-dev and then try pip3 install Pillow --no-binary :all: again.

@mightylastingcode
Copy link
Author

mightylastingcode commented Nov 8, 2021 via email

@mightylastingcode
Copy link
Author

/home/pi/.pyenv/versions/3.9.7/bin/python -m venv ./venv

I want to comment on this line. I can't use "python3 -m venv ./venv" because pyenv is not able to redirect the 3.9.7 python path (pyenv local 3.9.7) with Raspbian Pi Buster OS. I am still waiting for the pyenv team to solve this issue.

I just want to use a higher version of Python to run Pillow. The default Python3 is 3.7.4 with Raspian Pi Buster OS.

I want to say this so that others may be puzzled why I need to do it this way.

@radarhere
Copy link
Member

Ok, unless I misunderstand then, this is resolved.

@mightylastingcode
Copy link
Author

Yes. The issue is resolved now. You can close it. Thank you.

@radarhere radarhere added the Installation Usually a problem with … label Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Installation Usually a problem with … Linux
Projects
None yet
Development

No branches or pull requests

2 participants