django-cms / django-filer

File and Image Management Application for django
https://django-filer.readthedocs.io/
Other
1.73k stars 575 forks source link

`ImportError ... symbol not found` from reportlab on Apple Silicon #1283

Closed bhrutledge closed 1 year ago

bhrutledge commented 2 years ago

See also https://github.com/SmileyChris/easy-thumbnails/issues/585#issuecomment-1049776338 and https://github.com/django-cms/django-filer/issues/1277.

This looks like a bug in reportlab, which seems to be discussed in these threads:

Here's a minimal reproducing script, running in a fresh Python 3.9 virtual environment on an M1 MacBook Air:

% python3 -m venv venv-reportlab && source venv-reportlab/bin/activate && pip install -U setuptools pip wheel

% which python3 && python3 -V
/private/tmp/venv-reportlab/bin/python3
Python 3.9.6

% pip install django-filer
...
Successfully installed Unidecode-1.1.2 asgiref-3.5.0 cssselect2-0.4.1 django-3.2.12 django-filer-2.1.2 django-js-asset-2.0.0 django-mptt-0.13.4 django-polymorphic-3.0.0 easy-thumbnails-2.8.1 lxml-4.8.0 pillow-9.0.1 pytz-2021.3 reportlab-3.6.7 sqlparse-0.4.2 svglib-1.2.1 tinycss2-1.1.1 webencodings-0.5.1

% python3 -c '
from django.conf import settings
settings.configure(
    INSTALLED_APPS=[
        "django.contrib.contenttypes",
        "django.contrib.auth",
        "easy_thumbnails",
        "filer",
    ]
)

import django
django.setup()
'
Traceback (most recent call last):
...
  File "/private/tmp/venv-reportlab/lib/python3.9/site-packages/filer/fields/multistorage_file.py", line 9, in <module>
    from easy_thumbnails import fields as easy_thumbnails_fields
  File "/private/tmp/venv-reportlab/lib/python3.9/site-packages/easy_thumbnails/fields.py", line 2, in <module>
    from easy_thumbnails import files
  File "/private/tmp/venv-reportlab/lib/python3.9/site-packages/easy_thumbnails/files.py", line 17, in <module>
    from easy_thumbnails.VIL.Image import load
  File "/private/tmp/venv-reportlab/lib/python3.9/site-packages/easy_thumbnails/VIL/Image.py", line 7, in <module>
    from reportlab.graphics import renderSVG
  File "/private/tmp/venv-reportlab/lib/python3.9/site-packages/reportlab/graphics/renderSVG.py", line 22, in <module>
    from .renderPM import _getImage
  File "/private/tmp/venv-reportlab/lib/python3.9/site-packages/reportlab/graphics/renderPM.py", line 20, in <module>
    from .utils import setFont as _setFont, RenderPMError
  File "/private/tmp/venv-reportlab/lib/python3.9/site-packages/reportlab/graphics/utils.py", line 9, in <module>
    from . _renderPM import makeT1Font
ImportError: dlopen(/private/tmp/venv-reportlab/lib/python3.9/site-packages/reportlab/graphics/_renderPM.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_FT_Done_Face'

A workaround is to install reportlab from source:

% pip freeze | xargs pip uninstall -y

% pip install --no-binary reportlab django-filer
...
  Running setup.py install for reportlab ... done
Successfully installed Unidecode-1.1.2 asgiref-3.5.0 cssselect2-0.4.1 django-3.2.12 django-filer-2.1.2 django-js-asset-2.0.0 django-mptt-0.13.4 django-polymorphic-3.0.0 easy-thumbnails-2.8.1 lxml-4.8.0 pillow-9.0.1 pytz-2021.3 reportlab-3.6.7 sqlparse-0.4.2 svglib-1.2.1 tinycss2-1.1.1 webencodings-0.5.1

With that, the python3 -c command above runs without error.

The same error can be seen running tox -e py38-dj32-noswap in the django-filer repo.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This will now be closed due to inactivity, but feel free to reopen it.