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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With