#3190·devenv

Python venv is not activated for tasks

Author: MaddyGuthridgeCreated Sep 16, 2026Updated Sep 16, 2026
Labelsbug

Describe the bug

I have a task that depends on dependencies that I have configured in my Python virtual environment. When I try to run this task, it fails as the build cannot find python libraries that it needs. When I attempt to reproduce this in an interactive shell, the venv is activated correctly.

To reproduce

nix
# devenv.nix
{ pkgs, lib, config, inputs, ... }:

{
  languages.python = {
    enable = true;
    venv = {
      enable = true;
    };
  };

  tasks = {
    "venv:check" = {
      exec = ''
        which python
        exit 1  # To make output easily visible
      '';
    };
  };
}

Running the task. Observe that the python path points to the nix store.

bash
$ devenv tasks run -v venv:check
✓ Validating lock 1 files                                                       0ms
✓ Reading config.cachix.enable 160 files                                        0ms
✓ Configuring cachix                                                            0ms
  └ ✓ Reading config.cachix.pull                                                0ms
  └ ✓ Reading config.cachix.push                                                0ms
✓ Configuring shell                                                            2.3s
  └ ✓ Evaluating shell 1895 files                                              2.3s
    └ ✓ Querying  tasks.json from cache.nixos.org                             398ms
    └ ✓ Building  venv-check 1 lines                                           35ms
    └ ✓ Building  tasks.json 1 lines                                           46ms
    └ ✓ Building  devenv-shell 1 lines                                         94ms
    └ ✓ Building  devenv-shell-env                                            186ms
✓ Loading tasks                                                                 3ms
  └ ✓ Evaluating devenv.config.task.config                                      3ms
✗ Running tasks 1/1                                                             3ms
  └ ✗ venv:check failed → /nix/store/pndwg6ngyssngw8l2f2gza23qq9ra1pp-python…   3ms
  │ /nix/store/pndwg6ngyssngw8l2f2gza23qq9ra1pp-python3-3.14.7-env/bin/python
  × Some tasks failed

Running manually from the shell. Observe that the venv was automatically activated.

$ devenv shell
✓ Validating lock 1 files                                                       0ms
✓ Configuring shell                                                             0ms
  └ ✓ Configuring cachix                                                        0ms
  └ ✓ Evaluating shell cached                                                   0ms
✓ Loading tasks                                                                 0ms
  └ ✓ Evaluating devenv.config.task.config cached                               0ms
✓ Running tasks                                                                3.3s
  └ ✓ devenv:enterShell                                                         6ms
    └ ✓ devenv:python:virtualenv 4 lines → ~/Source/COMP/9242/devenv-test      3.3s
    └ ✓ devenv:files:cleanup                                                    0ms
  └ ✓ devenv:enterTest skipped                                                  0ms
✨ devenv 2.2.2 is out of date. Please update to 2.3.1: https://devenv.sh/getting-st
arted/#installation
(devenv) $  which python
/home/maddy/Source/COMP/9242/devenv-test/.devenv/state/venv/bin/python

**Version**
<!--
Paste the output of `devenv version` here or tell us if you're using flakes.
-->
* devenv 2.2.2 (x86_64-linux)
* NixOS (latest devenv from unstable unless I rebuild my entire system, which I cannot do currently)