Search code examples
pythonmacoshomebrewreportlab

Symbol not found in flat namespace '_FT_Done_Face' from reportlab with Python@3.9 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

  • 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!