'Symbol not found in flat namespace '_FT_Done_Face' from reportlab with [email protected] on macOS 12

I have a django project using easy-thumbnail as a dependency.

Installing all packages with pip is working as expected, but when I try to run my app I get this error:

Invalid template library specified. ImportError raised when trying to load 'backend.templatetags.get_thumbnail': dlopen(/opt/homebrew/lib/python3.9/site-packages/reportlab/graphics/_renderPM.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_FT_Done_Face'

The error is raised from reportlab which is a dependency of easy-thumbnail. As far as I understand, reportlab is not able to find freetype. But it is installed correctly imho.

I'm using macOS 12.0.1

I installed Python and freetype via Homebrew. pkg-config says, that freetype2 is available at the expected paths.

What am I doing wrong? How can I fix this?


Edit

I did otool -l on the failing .so-file and this is, what I get (here I'm running it again in a venv):

/Users/markusgerards/.pyenv/versions/myapp/lib/python3.9/site-packages/reportlab/graphics/_renderPM.cpython-39-darwin.so:
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

I suspect that freetype should be listed there... right?



Solution 1:[1]

I reinstalled reportlab with this command:

pip install reportlab --force-reinstall --no-cache-dir --global-option=build_ext

This forced pip to actually build the package and now everythings works as intended!

Solution 2:[2]

I use M1 Mac Air with Python 3.8 and for some reason, solution from @gerricom didn't work out for me. But, simple pip uninstall reportlab and then pip install reportlab solved the problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gerricom
Solution 2 Ramil Suleimanov