Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

languages.python.package = pkgs.python310.withPackages (…) does not work #1218

Open
dpaetzel opened this issue May 21, 2024 · 5 comments
Open
Labels
bug Something isn't working

Comments

@dpaetzel
Copy link

Thank you for developing and maintaining this awesome project! 🙂

Describe the bug

I'm trying to specify Python packages by

languages.python = {
  enable = true;
  package =
    pkgs.python310.withPackages (ps: [
      ps.xlrd
    ]);
};

but this does not work, i.e.

nix develop --impure --command python -c 'import xlrd; print("yeah!")'

yields

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'xlrd'

Interestingly, as also described in this comment, instead specifying

packages = with pkgs.python310Packages; [ xlrd ];
languages.python.enable = true;

does work but does not seem to be preferable due to the uncoupling of Python packages and interpreter. Or maybe I misunderstood something? Of course I could use let and friends to extract python310 somehow but that seems clunky.

To reproduce

https://gist.github.com/dpaetzel/303644fc1aa7863a4d0194c9f205b4b1

Version

I'm using Flakes.

@dpaetzel dpaetzel added the bug Something isn't working label May 21, 2024
@domenkozar
Copy link
Member

For that to work you'll need to use https://github.com/cachix/devenv-nixpkgs for nixpkgs

@therealpxc
Copy link
Contributor

For that to work you'll need to use https://github.com/cachix/devenv-nixpkgs for nixpkgs

Is this just because of the way the devenv's Python language module invokes Nixpkgs' Python wrapper via callPackage, in that if the wrapper's interface or behavior changes, that callPackage invocation might no longer have the desired effect?

@srounce
Copy link

srounce commented May 24, 2024

I'm trying to do the same thing and set the nixpkgs input to

nixpkgs:
  url: github:cachix/devenv-nixpkgs

and I now get the following error when trying to enter the shell

Updating devenv.lock ...
error:
       … while updating the lock file of flake 'git+file:///Users/s/repos/myproject'

       … while updating the flake input 'nixpkgs'

       error:
       error: flake '«github:cachix/devenv-nixpkgs/aaadd7348d76c258d788dcc6712276abb78393ab»/.devenv.flake.nix' does not exist

✖ Command produced the following output:



✔ Updating devenv.lock in 0.3s.
Error:   × Command `/nix/store/y2w7cpc5b7l43hrpkzc47dgyshjcc7c0-nix-2.21-devenv/bin/nix --show-trace --extra-experimental-features nix-
  │ command --extra-experimental-features flakes --option warn-dirty false --option eval-cache false --keep-going --max-jobs 4
  │ flake update` failed with with exit code 1

@YPares
Copy link

YPares commented May 24, 2024

@srounce I had the same problem, it should actually be:

inputs:
    nixpkgs:
        url: github:cachix/devenv-nixpkgs/rolling

But @domenkozar even using it, the original error (import error) remains.
I'm using devenv directly, not in a flake.

@senorsmile
Copy link

@srounce I had the same problem, it should actually be:

inputs:
    nixpkgs:
        url: github:cachix/devenv-nixpkgs/rolling

But @domenkozar even using it, the original error (import error) remains. I'm using devenv directly, not in a flake.

I have run into the same issue trying out devenv. @domenkozar mentioned that you can put them in directly now:
#601 (comment)

That works for some, but for others, it doesn't seem to grab all the dependencies. E.g. boto3 fails import due to a missing dependency. I manually put that in, but another dep popped up. I ended up having to specify 3 deps manually:

    pkgs.python3Packages.boto3
        pkgs.python3Packages.botocore
        pkgs.python3Packages.jmespath
        pkgs.python3Packages.dateutil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants