{description="A very basic flake";inputs={nixpkgs.url="github:nixos/nixpkgs?ref=nixos-unstable";};outputs={self,nixpkgs}:letpkgs=nixpkgs.legacyPackages.x86_64-linux;my-python=pkgs.python312.withPackages(python-pkgs:[python-pkgs.matplotlib]);in{devShells.x86_64-linux.default=pkgs.mkShell{packages=withpkgs;[my-python];};};}
{description="A very basic flake";inputs={nixpkgs.url="github:nixos/nixpkgs?ref=nixos-unstable";};outputs={self,nixpkgs}:letpkgs=nixpkgs.legacyPackages.x86_64-linux;in{devShells.x86_64-linux.default=pkgs.mkShell{packages=withpkgs;[uv];};};}
[bombrary@nixos:~/example]$ uv run python main.py
Traceback (most recent call last):
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/numpy/_core/__init__.py", line 23, in <module>
from . import multiarray
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/numpy/_core/multiarray.py", line 10, in <module>
from . import overrides
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/numpy/_core/overrides.py", line 8, in <module>
from numpy._core._multiarray_umath import (
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/numpy/__init__.py", line 114, in <module>
from numpy.__config__ import show as show_config
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/numpy/__config__.py", line 4, in <module>
from numpy._core._multiarray_umath import (
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/numpy/_core/__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.12 from "/home/bombrary/example/.venv/bin/python3"
* The NumPy version is: "2.1.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: libstdc++.so.6: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/bombrary/example/main.py", line 1, in <module>
import matplotlib
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/matplotlib/__init__.py", line 159, in <module>
from . import _api, _version, cbook, _docstring, rcsetup
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/matplotlib/cbook.py", line 24, in <module>
import numpy as np
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/numpy/__init__.py", line 119, in <module>
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
{description="A very basic flake";inputs={nixpkgs.url="github:nixos/nixpkgs?ref=nixos-unstable";};outputs={self,nixpkgs}:letpkgs=nixpkgs.legacyPackages.x86_64-linux;in{devShells.x86_64-linux.default=pkgs.mkShell{packages=withpkgs;[uv];LD_LIBRARY_PATH=pkgs.lib.makeLibraryPath(withpkgs;[libgcc.lib]);};};}
[bombrary@nixos:~/example]$ uv run python main.py
/home/bombrary/example/main.py:6: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/matplotlib/backends/backend_tkagg.py", line 1, in <module>
from . import _backend_tk
File "/home/bombrary/example/.venv/lib/python3.12/site-packages/matplotlib/backends/_backend_tk.py", line 9, in <module>
import tkinter as tk
File "/nix/store/h3i0acpmr8mrjx07519xxmidv8mpax4y-python3-3.12.5/lib/python3.12/tkinter/__init__.py", line 38, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_tkinter'
そもそもuvから動くPythonはいったい何者なのだろうか? これは uv python list コマンドで確認できる。どうやら /nix/store/ にあるPythonを参照しているようだ。つまりnixpkgs上で管理されているPythonである。
{description="A very basic flake";inputs={nixpkgs.url="github:nixos/nixpkgs?ref=nixos-unstable";};outputs={self,nixpkgs}:letpkgs=nixpkgs.legacyPackages.x86_64-linux.extend(final:prev:{my-python312=prev.python312.override{self=final.my-python;x11Support=true;};uv=(prev.uv.override{python3Packages=final.my-python.pkgs;});});in{devShells.x86_64-linux.default=pkgs.mkShell{packages=withpkgs;[uv];LD_LIBRARY_PATH=pkgs.lib.makeLibraryPath(withpkgs;[libgcc.lib]);};};}
{description="A very basic flake";inputs={nixpkgs.url="github:nixos/nixpkgs?ref=nixos-unstable";};outputs={self,nixpkgs}:letpkgs=nixpkgs.legacyPackages.x86_64-linux.extend(final:prev:{my-python312=prev.python312.override{self=final.my-python312;x11Support=true;};my-python311=prev.python311.override{self=final.my-python311;x11Support=true;};uv=(prev.uv.override{python3Packages=final.my-python312.pkgs;});});in{devShells.x86_64-linux.default=pkgs.mkShell{packages=withpkgs;[uvmy-python311];LD_LIBRARY_PATH=pkgs.lib.makeLibraryPath(withpkgs;[libgcc.lib]);};};}
at 19:40:22 ❯ ssh -Y bombrary@192.168.11.11
(bombrary@192.168.11.11) Password:
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Sun Sep 15 19:10:40 2024 from 192.168.11.6
[bombrary@nixos:~]$ nix run 'nixpkgs#xorg.xeyes'