Skip to content

python3Packages.virtualenv: crashes with "No module named 'packaging'" after update to 21.14.12 #587111

Open

Description

@benabraham

Nixpkgs version

  • Unstable (26.11)

Describe the bug

Hi, I'm fairly new to NixOS, so sorry if I'm missing something but at least some contribution 😅.

After updating my flake's nixpkgs, pre-commit stopped working for me. It fails while setting up the Python hook environments. When I dug into it, the problem seems to be virtualenv itself: just running virtualenv --version crashes with ModuleNotFoundError: No module named 'packaging'.

If I read things correctly, the update to 21.14.12 (#577206) is where this started. On PyPI, virtualenv 21.14.12 lists packaging>=26.3 as a required dependency, but the nixpkgs expression still only has distlib, filelock, platformdirs and python-discovery in dependencies. I think that packaging needs to be added there, but I'm not 100% sure that's the whole story seems to work for me.

Steps to reproduce

  1. nix run github:NixOS/nixpkgs/177d0540942fb205af6993b1d5fa0b57799e09f8#python3Packages.virtualenv -- --version
  2. It fails with a traceback ending in ModuleNotFoundError: No module named 'packaging'.

Minimal reproducer

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/177d0540942fb205af6993b1d5fa0b57799e09f8";

  outputs =
    { nixpkgs, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in
    {
      packages.${system}.default = pkgs.python3Packages.virtualenv;
    };
}


Command: `nix run . -- --version`

Expected behaviour

virtualenv --version prints the version, and tools that use virtualenv (like pre-commit) can create their environments again.

Screenshots

No response

Relevant log output

File ".../python3.14-virtualenv-21.14.12/lib/python3.14/site-packages/virtualenv/seed/wheels/acquire.py", line 13, in <module>
    from packaging.specifiers import InvalidSpecifier, Specifier
ModuleNotFoundError: No module named 'packaging'

Additional context

For now I'm working around it with this overlay in my flake, and it works for me — pre-commit runs fine again:

pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
  (pyFinal: pyPrev: {
    virtualenv = pyPrev.virtualenv.overridePythonAttrs (old: {
      dependencies = old.dependencies ++ [ pyFinal.packaging ];
    });
  })
];

I'm not sure whether that's the right way to fix it properly in nixpkgs, or why the build checks
didn't catch it. Maybe the import check only imports the top-level virtualenv module and never
reaches the part that needs packaging?

If it helps, I'm happy to open a PR that adds packaging to the dependencies. Just let me know if
you'd like me to, or if someone who knows this package better would rather handle it.

Disclosure: I used an LLM assistant (Claude Opus 5.5) to help track down the cause. I reproduced the failure myself and reviewed and edited the text before posting.

System metadata

🐳 SmokingCat dev env ready (Python 3.15.2, Node v26.13.0)

  • system: "x86_64-linux"
  • host os: Linux 7.3.3, NixOS, 26.05 (Yarara), 26.05.20261108.ac588ef
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.34.9
  • channels(root): "home-manager-25.05.tar.gz, nixos-25.05, nixos-unstable"
  • nixpkgs: /nix/store/7sa2x9c9566lfxkaxs36n3z4yayl5cy4-source

Notify maintainers

The package doesn't seem to have any maintainers listed, so I'm pinging the author of the version update, hope that's ok: @FliegendeWurst


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Activity

  1. added
    0.kind: bug
    on Nov 12, 2026
  2. FliegendeWurst commented on Nov 13, 2026

    @FliegendeWurst
    Member

    Fix in #587178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions