Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In nixos, what is the difference between installing from pkgs or python311Packages

Tags:

python

nix

nixos

I had an issue when I installed Yapf this way:

environment.systemPackages = with pkgs; [
(python311.withPackages(ps: with ps; [
  toml
  python-lsp-server
  pyls-isort
  flake8
]))
pkgs.yapf
];

This gave me the error:

$ yapf autoapp.py yapf: toml package is needed for using pyproject.toml as a configuration file

And I solved when I did:

environment.systemPackages = with pkgs; [
(python311.withPackages(ps: with ps; [
  toml
  python-lsp-server
  pyls-isort
  flake8
  yapf
]))
];

Why was the first configuration giving me an installed version of yapf that couldn't import toml?

like image 852
Harm Avatar asked Mar 10 '26 03:03

Harm


1 Answers

These are the same package - you can see this by checking the source links from the package search page. Adding it to withPackages links the Python package with the interpreter, making it possible to run things like python -m yapf … or import yapf within the Python REPL. If you simply list pkgs.yapf at the top level, the package isn't linked to the Pyython interpreter, and so only things like man pages and executables are available in the resulting environment.

like image 129
l0b0 Avatar answered Mar 11 '26 15:03

l0b0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!