Skip to content

Fix: Use sys.executable -m pipenv instead of bare pipenv command#6491

Merged
matteius merged 1 commit intomainfrom
fix/pipenv-check-path-6042
Dec 10, 2025
Merged

Fix: Use sys.executable -m pipenv instead of bare pipenv command#6491
matteius merged 1 commit intomainfrom
fix/pipenv-check-path-6042

Conversation

@matteius
Copy link
Copy Markdown
Member

Summary

When running python -m pipenv check in an environment where pipenv is not on $PATH, the check and scan commands would fail with:

FileNotFoundError: [Errno 2] No such file or directory: 'pipenv'

Problem

The get_requirements() function in both check.py and scan.py invoked pipenv requirements as a subprocess using the bare pipenv command:

run_command(["pipenv", "requirements"], ...)

This assumes pipenv is on the system's $PATH, which may not be true when:

  • Running with python -m pipenv directly
  • Using a non-standard installation
  • Running in restricted environments (e.g., Docker containers with minimal PATH)

Fix

Update get_requirements() to use sys.executable to invoke pipenv as a module:

run_command([sys.executable, "-m", "pipenv", "requirements"], ...)

This ensures the command works regardless of whether pipenv is on the PATH.

Files Changed

  • pipenv/routines/check.py - Updated get_requirements() function
  • pipenv/routines/scan.py - Updated get_requirements() function

Fixes #6042


Pull Request opened by Augment Code with guidance from the PR author

When running 'python -m pipenv check' in an environment where pipenv
is not on $PATH, the check and scan commands would fail because they
invoked 'pipenv requirements' as a subprocess using the bare 'pipenv'
command.

This fix updates get_requirements() in both check.py and scan.py to
use [sys.executable, '-m', 'pipenv', 'requirements'] instead of
['pipenv', 'requirements'], ensuring the command works regardless of
whether pipenv is on the PATH.

Fixes #6042
@matteius matteius merged commit a65c9b2 into main Dec 10, 2025
19 of 20 checks passed
@matteius matteius deleted the fix/pipenv-check-path-6042 branch December 10, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python -m pipenv check assumes pipenv is on $PATH

1 participant