[QGIS-Developer] Problems with matplotlib with QGIS LTR on MacOS

Paolo Tormene paolo.tormene at globalquakemodel.org
Wed Jan 11 05:50:46 PST 2023


Hello everybody,
I was experiencing issues installing a QGIS Python plugin on MacOS 12.6
and, after some investigation, I found out that the problem seems to happen
only with the current QGIS-LTR (3.22) and not with the latest release
(3.28.2-Firenze).
The problem occurs for instance when attempting to do something like the
following from the QGIS Python console:
from matplotlib import pyplot

Traceback (most recent call last):
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/code.py",
line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/matplotlib-3.3.0-py3.8-macosx-10.13.0-x86_64.egg/matplotlib/pyplot.py",
line 36, in <module>
    import matplotlib.colorbar
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/matplotlib-3.3.0-py3.8-macosx-10.13.0-x86_64.egg/matplotlib/colorbar.py",
line 44, in <module>
    import matplotlib.contour as contour
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/matplotlib-3.3.0-py3.8-macosx-10.13.0-x86_64.egg/matplotlib/contour.py",
line 17, in <module>
    import matplotlib.text as text
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/matplotlib-3.3.0-py3.8-macosx-10.13.0-x86_64.egg/matplotlib/text.py",
line 16, in <module>
    from .textpath import TextPath  # Unused, but imported by others.
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/matplotlib-3.3.0-py3.8-macosx-10.13.0-x86_64.egg/matplotlib/textpath.py",
line 11, in <module>
    from matplotlib.mathtext import MathTextParser
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/matplotlib-3.3.0-py3.8-macosx-10.13.0-x86_64.egg/matplotlib/mathtext.py",
line 27, in <module>
    from PIL import Image
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/Pillow-7.2.0-py3.8-macosx-10.13.0-x86_64.egg/PIL/Image.py",
line 94, in <module>
    from . import _imaging as core
  File
"/Applications/QGIS-LTR.app/Contents/MacOS/../Resources/python/qgis/utils.py",
line 888, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError:
dlopen(/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.8/site-packages/Pillow-7.2.0-py3.8-macosx-10.13.0-x86_64.egg/PIL/_
imaging.cpython-38-darwin.so, 0x0002): Library not loaded:
'/opt/X11/lib/libxcb.1.dylib'
  Referenced from:
'/Applications/QGIS-LTR.app/Contents/Resources/python/site-packages/pillow-7.2.0-py3.8-macosx-10.13.0-x86_64.egg/PIL/_
imaging.cpython-38-darwin.so'
  Reason: tried: '/opt/X11/lib/libxcb.1.dylib' (no such file),
'/usr/local/lib/libxcb.1.dylib' (no such file), '/usr/lib/libxcb.1.dylib'
(no such file)

Cheers,
Paolo
-- 

*PAOLO TORMENE* senior software developer +39 0382 5169882

*GLOBAL EARTHQUAKE MODEL * working together to assess risk

*GEM -* globalquakemodel.org <http://www.globalquakemodel.org> *T -*
@GEMwrld <http://twitter.com/GEMwrld> *F -* GEMwrld
<http://www.facebook.com/GEMwrld>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20230111/c9653f27/attachment-0001.htm>


More information about the QGIS-Developer mailing list