SmileyChris / easy-thumbnails

Easy thumbnails for Django
http://easy-thumbnails.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
1.37k stars 312 forks source link

2.8 release breaks on M1 / python 3.9 - symbol not found in flat namespace '_FT_Done_Face' #585

Closed xobed closed 2 years ago

xobed commented 2 years ago

Apple M1 / Python 3.9.5

Release 2.7.2 works OK Error after upgrading to 2.8

 File "/Projects/project/.venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 96, in handle
    from easy_thumbnails.templatetags.thumbnail import thumbnail_url
  File "/Projects/project/.venv/lib/python3.9/site-packages/easy_thumbnails/templatetags/thumbnail.py", line 12, in <module>
    self.run(**options)
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 103, in run
    from easy_thumbnails.files import get_thumbnailer
  File "/Projects/project/.venv/lib/python3.9/site-packages/easy_thumbnails/files.py", line 17, in <module>
    autoreload.run_with_reloader(self.inner_run, **options)
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 638, in run_with_reloader
    from easy_thumbnails.VIL.Image import load
  File "/Projects/project/.venv/lib/python3.9/site-packages/easy_thumbnails/VIL/Image.py", line 7, in <module>
    start_django(reloader, main_func, *args, **kwargs)
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 623, in start_django
    from reportlab.graphics import renderSVG
  File "/Projects/project/.venv/lib/python3.9/site-packages/reportlab/graphics/renderSVG.py", line 23, in <module>
    from .renderPM import _getImage
  File "/Projects/project/.venv/lib/python3.9/site-packages/reportlab/graphics/renderPM.py", line 21, in <module>
    reloader.run(django_main_thread)
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/utils/autoreload.py", line 328, in run
    from .utils import setFont as _setFont, RenderPMError
  File "/Projects/project/.venv/lib/python3.9/site-packages/reportlab/graphics/utils.py", line 9, in <module>
    autoreload_started.send(sender=self)
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 180, in send
    from . _renderPM import makeT1Font
ImportError: dlopen(/Projects/project/.venv/lib/python3.9/site-packages/reportlab/graphics/_renderPM.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_FT_Done_Face'
    return [
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 181, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/autoreload.py", line 44, in watch_for_template_changes
    for directory in get_template_directories():
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/autoreload.py", line 17, in get_template_directories
    for backend in engines.all():
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/utils.py", line 90, in all
    return [self[alias] for alias in self]
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/utils.py", line 90, in <listcomp>
    return [self[alias] for alias in self]
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/utils.py", line 81, in __getitem__
    engine = engine_cls(params)
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/backends/django.py", line 25, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries
    for name in get_package_libraries(pkg):
  File "/Projects/project/.venv/lib/python3.9/site-packages/django/template/backends/django.py", line 123, in get_package_libraries
    raise InvalidTemplateLibrary(
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'easy_thumbnails.templatetags.easy_thumbnails_tags': dlopen(/Projects/project/.venv/lib/python3.9/site-packages/reportlab/graphics/_renderPM.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '_FT_Done_Face'
jrief commented 2 years ago

You have to install reportlabs as specified in the dependencies.

Sawrz commented 2 years ago

I can't confirm that it's the solution to the problem. For example, I run an M1 Max processor, and I get the same error. Suffice to say that reportlabs and the other dependencies are installed. I tried to install the dependencies manually in case something went wrong, but everything was already there. Version 2.7.2 works fine, as @xobed mentioned. Maybe something about the ARM architecture of the M1 chips version 2.8.0 or a dependency doesn't like. I remember scipy having a similar problem where installing on an M1 machine wasn't possible.

The error occurred during the migration process. Here are all packages installed on my venv for my Django project:

asgiref==3.4.1
bleach==4.1.0
cssselect2==0.4.1
Django==3.2.9
django-bleach==1.0.0
django-environ==0.8.1
easy-thumbnails==2.7.2
flashtext==2.7
gunicorn==20.1.0
lxml==4.7.1
Markdown==3.3.6
numpy==1.21.4
packaging==21.3
Pillow==8.4.0
psycopg2==2.9.2
pyparsing==3.0.6
pytz==2021.3
reportlab==3.6.3
six==1.16.0
sqlparse==0.4.2
svglib==1.1.0
tinycss2==1.1.1
webencodings==0.5.1
bhrutledge commented 2 years ago

I think this issue should be re-opened due to what seems like a bug in reportlab, which seems to be discussed in these threads:

I was able to reproduce this in a fresh Python 3.9 virtual environment on an M1 MacBook Air:

% python3 -m venv venv-reportlab && source venv-reportlab/bin/activate

% python3 -V
Python 3.9.6

% pip install -U setuptools pip wheel

% pip install easy-thumbnails
...
Successfully installed asgiref-3.5.0 cssselect2-0.4.1 django-4.0.2 easy-thumbnails-2.8.1 lxml-4.8.0 svglib-1.2.1

% python3 -c "from easy_thumbnails.VIL.Image import load"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  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 easy-thumbnails
...
  Running setup.py install for reportlab ... done
Successfully installed asgiref-3.5.0 cssselect2-0.4.1 django-4.0.2 easy-thumbnails-2.8.1 lxml-4.8.0 pillow-9.0.1 reportlab-3.6.7 sqlparse-0.4.2 svglib-1.2.1 tinycss2-1.1.1 webencodings-0.5.1

% python3 -c "from easy_thumbnails.VIL.Image import load"