-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Bug summary
On NixOS, we'd like to update from 3.8.4
to 3.9.0
, but we experience an issue to import matplotlib
. The symptom is (first discussed on discourse here):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/doron/repos/matplotlib/out/lib/python3.11/site-packages/matplotlib/__init__.py", line 159, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "/home/doron/repos/matplotlib/out/lib/python3.11/site-packages/matplotlib/rcsetup.py", line 28, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/home/doron/repos/matplotlib/out/lib/python3.11/site-packages/matplotlib/colors.py", line 57, in <module>
from matplotlib import _api, _cm, cbook, scale
File "/home/doron/repos/matplotlib/out/lib/python3.11/site-packages/matplotlib/scale.py", line 22, in <module>
from matplotlib.ticker import (
File "/home/doron/repos/matplotlib/out/lib/python3.11/site-packages/matplotlib/ticker.py", line 144, in <module>
from matplotlib import transforms as mtransforms
File "/home/doron/repos/matplotlib/out/lib/python3.11/site-packages/matplotlib/transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: /home/doron/repos/matplotlib/out/lib/python3.11/site-packages/matplotlib/_path.cpython-311-x86_64-linux-gnu.so: undefined symbol: _ZN3agg10curve3_div4initEdddddd
It includes all the g++
commands used to compile the shared objects. Here's the command that produces _path.cpython-311-x86_64-linux-gnu.so
:
g++ \
-o src/_path.cpython-311-x86_64-linux-gnu.so \
src/_path.cpython-311-x86_64-linux-gnu.so.p/py_converters.cpp.o \
src/_path.cpython-311-x86_64-linux-gnu.so.p/py_converters_11.cpp.o \
src/_path.cpython-311-x86_64-linux-gnu.so.p/_path_wrapper.cpp.o \
-flto \
-Wl,--as-needed \
-Wl,--allow-shlib-undefined \
-Wl,-O1 \
-shared \
-fPIC \
extern/agg24-svn/libagg.a
Code for reproduction
Compile it on a Nix system, not necessarily with Nix, but use Nix provided Python dependencies, and not those from a pip virtual environment. If you happen to have Nix installed, you can simply clone my nixFlake
branch, and run:
nix --option extra-experimental-features "flakes nix-command" \
develop --command python -m pip install \
--config-settings=setup-args="-Dsystem-freetype=true" \
--config-settings=setup-args="-Dsystem-qhull=true" \
--config-settings=builddir=build \
--prefix dist/nix \
--no-build-isolation \
".[dev]"
Verify that Nix' Python interpreter includes the path to the just compiled matplotlib
files in the dist/nix
directory:
nix --option extra-experimental-features "flakes nix-command" \
develop --command python -c 'print("\n".join(__import__("sys").path))'
And then try to import matplotlib
with the same Python interpreter with:
nix --option extra-experimental-features "flakes nix-command" \
develop --command python -c 'matplotlib'
If you'd change every python312
in flake.nix
with python311
- you'd test Python 3.11 instead, where the same error appears.
Actual outcome
Error as described above.
Expected outcome
No error.
Additional information
This error wasn't present with our build system on 3.8.4.
Operating system
NixOS
Matplotlib Version
3.9.0
Matplotlib Backend
Irrelevant
Python version
3.11 & 3.12
Jupyter version
Irrelevant.
Installation
git checkout