{"id":10273,"library":"subprocess-run","title":"Subprocess Run","description":"subprocess-run is a Python library that extends the standard `subprocess` module, offering a simplified `run` function with opinionated defaults like `check=True` and stripped output. It provides a more convenient way to execute external commands compared to the standard library's `subprocess.Popen`. The current version is 0.0.8, with the last release approximately two years ago, indicating a maintenance-focused project rather than active development.","status":"maintenance","version":"0.0.8","language":"en","source_language":"en","source_url":"https://github.com/xando/subprocess.run","tags":["subprocess","process","shell","command-execution"],"install":[{"cmd":"pip install subprocess-run","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The 'run' function is exposed directly, not as an attribute of the top-level package, and the package name is `subprocess_run`, not `subprocess.run` (stdlib).","wrong":"import subprocess_run","symbol":"run","correct":"from subprocess_run import run"},{"note":"The 'popen' function is exposed directly, similar to 'run'.","wrong":"import subprocess_run.popen","symbol":"popen","correct":"from subprocess_run import popen"}],"quickstart":{"code":"from subprocess_run import run\n\n# Execute a simple command\nprint(\"Executing a simple command:\")\ntry:\n    # run() returns (exit_code, stdout, stderr) by default with return_tuple=True\n    exit_code, stdout, stderr = run([\"echo\", \"Hello from subprocess-run!\"])\n    print(f\"Success: '{stdout.strip()}'\")\n    print(f\"Exit code: {exit_code}\")\nexcept Exception as e:\n    print(f\"Error: {e}\")\n\n# Command failing with default check=True\n# 'false' is a common Unix command that always exits with a non-zero status.\n# On Windows, you might use ['cmd', '/c', 'exit 1']\nprint(\"\\nAttempting to run a command that will fail (check=True by default):\")\ntry:\n    run([\"false\"])\nexcept Exception as e:\n    print(f\"Caught expected error for failing command: {e}\") # e.g., CalledProcessError\n\n# Command with input data (stdin)\n# 'cat -' on Unix-like systems reads from stdin.\n# For cross-platform, a simple python script could echo stdin:\n# ['python', '-c', 'import sys; print(sys.stdin.read())']\nprint(\"\\nExecuting a command with input data:\")\ntry:\n    input_text = \"Data for stdin\"\n    _, output, _ = run([\"cat\", \"-\"], input_data=input_text.encode('utf-8'))\n    print(f\"Input: '{input_text}', Output from stdin command: '{output.strip()}'\")\nexcept Exception as e:\n    print(f\"Error with input_data: {e}\")","lang":"python","description":"This quickstart demonstrates how to use the `subprocess_run.run` function for basic command execution, handling failing commands (due to default `check=True`), and providing input data via stdin using `input_data`."},"warnings":[{"fix":"Always consult the `subprocess-run` documentation for specific parameter usage. Be aware of the default `check=True` and `strip_result=True` and explicitly set them to `False` if standard library behavior is desired.","message":"The default behavior of `subprocess_run.run()` differs significantly from the standard library `subprocess.run()`. Key differences include: `check=True` by default (raises `CalledProcessError` on non-zero exit), `strip_result=True` by default (strips whitespace from stdout/stderr), `return_tuple=True` by default (returns `(exit_code, stdout, stderr)`), and it uses `input_data` for stdin instead of `input`.","severity":"gotcha","affected_versions":"0.0.1 - 0.0.8"},{"fix":"Evaluate if the current feature set meets your needs. For projects requiring active development, newer Python compatibility, or specific bug fixes, consider the standard `subprocess` module or more actively maintained alternatives if `subprocess-run` specific features are not critical.","message":"The `subprocess-run` library appears to be in maintenance mode, with the last release (0.0.8) and significant activity occurring over two years ago. This means it may not receive updates for new Python versions, security patches, or feature enhancements.","severity":"gotcha","affected_versions":"0.0.1 - 0.0.8"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed using `pip install subprocess-run`. Verify your import statement is `from subprocess_run import run` or `from subprocess_run import popen`.","cause":"The `subprocess-run` package is not installed or the import statement uses the incorrect module name.","error":"ModuleNotFoundError: No module named 'subprocess_run'"},{"fix":"Change `input=b'your data'` to `input_data=b'your data'` when calling `subprocess_run.run()`.","cause":"You are attempting to use the `input` keyword argument, which is present in the standard library `subprocess.run()`, but `subprocess_run.run()` uses `input_data` for providing data to stdin.","error":"TypeError: run() got an unexpected keyword argument 'input'"},{"fix":"Handle the `subprocess.CalledProcessError` exception if you expect the command to fail gracefully, or pass `check=False` to `run()` if you intend to process non-zero exit codes manually without raising an exception.","cause":"The command executed returned a non-zero exit status, and `subprocess_run.run()` has `check=True` by default, which raises a `CalledProcessError` in such cases.","error":"subprocess.CalledProcessError: Command '['false']' returned non-zero exit status 1."}]}