I am just starting out in developing a workflow in python to do mostly systems engineering and data science.
I found poetry2nix and chose this solution since it seemed to be the best of all worlds. Portable environment with poetry which manages all the python packages and then a flake to manage other dependencies and integrate well with nix.
However when importing matplotlib i get the following error:
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/marci/.cache/pypoetry/virtualenvs/app-ZnXbtN1Y-py3.11/lib/python3.11/site-packages/matplotlib/__init__.py", line 161, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "/home/marci/.cache/pypoetry/virtualenvs/app-ZnXbtN1Y-py3.11/lib/python3.11/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/home/marci/.cache/pypoetry/virtualenvs/app-ZnXbtN1Y-py3.11/lib/python3.11/site-packages/matplotlib/colors.py", line 57, in <module>
from matplotlib import _api, _cm, cbook, scale
File "/home/marci/.cache/pypoetry/virtualenvs/app-ZnXbtN1Y-py3.11/lib/python3.11/site-packages/matplotlib/scale.py", line 22, in <module>
from matplotlib.ticker import (
File "/home/marci/.cache/pypoetry/virtualenvs/app-ZnXbtN1Y-py3.11/lib/python3.11/site-packages/matplotlib/ticker.py", line 143, in <module>
from matplotlib import transforms as mtransforms
File "/home/marci/.cache/pypoetry/virtualenvs/app-ZnXbtN1Y-py3.11/lib/python3.11/site-packages/matplotlib/transforms.py", line 49, in <module>
from matplotlib._path import (
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
Steps to reproduce:
nix flake init --template github:nix-community/poetry2nix
nix develop
poetry add matplotlib
poetry run python
import matplotlib.plot as plt
I tried to fix it mostly with this thread but could not get it to work with any of the proposed solutions. The same error still persists.
If anyone has any experience in using python with nix or poetry2nix I would be very grateful for tips on how to fix this problem and what are general best practices when working with these tools.
I am on recent NixOS 23.11.