Skip to content

# pipeio_nb_exec: python_bin as string breaks subprocess

Goal

(promoted from note)

Context

(see source note)

Prompt

Fix the issue described in /storage2/arash/projects/projio/docs/log/issue/issue-arash-20260407-040507-512890.md. Read it first, then implement the proposed fix.

Acceptance Criteria

  • [ ]

Result

Completed in 196.8s (1 steps, model: opus)

Session: b82cd142-b149-4cfe-b170-250a82f0a7b0 Result note: /storage2/arash/worklog/workflow/captures/20260407-040906-fec71c/note.md

Output

Done. Here's a summary of the fix:

**Problem:** When `env` is set, `python_bin` was constructed as a single string `"conda run -n cogpy python"`, which `subprocess.run()` treated as a single executable path (element 0 of the list), causing `FileNotFoundError`.

**Fix across 3 files:**

1. **`src/projio/mcp/pipeio.py:1120`** — Changed `python_bin` from f-string to list: `[conda, "run", "-n", env, "python"]`

2. **`packages/pipeio/src/pipeio/notebook/lifecycle.py`** — Added `_python_prefix()` normalizer that handles `str | list[str] | None`. Updated `_require_jupytext()` and `_jupytext()` to use `[*prefix, "-m", "jupytext", ...]` instead of `[python_bin, "-m", ...]`. Updated type annotations on all functions that accept `python_bin`.

3. **`packages/pipeio/src/pipeio/mcp.py`** — Added same `_python_prefix()` helper. Updated `_has_papermill()` and the papermill cmd construction in `mcp_nb_exec` to use `[*prefix, ...]` pattern. Updated `python_bin` type annotation on `mcp_nb_exec`.

Backward compatible — plain string `python_bin` (e.g. `"/usr/bin/python3"`) still works via the normalizer.

## Next Steps

1. Run `make test` in both `projio` and `packages/pipeio` to verify nothing is broken by the type changes.
2. Test end-to-end by calling `pipeio_nb_exec` with a conda env to confirm jupytext sync and papermill execution work correctly.
3. Fix the related issue `issue-arash-20260407-033705-872924.md` which covers kernel/env option additions in the same `pipeio_nb_exec` feature area.