bash

raw JSON →
0.6 verified Fri May 01 auth: no python abandoned

Bash for Python is a library that allows you to run bash commands as Python function calls. Current version 0.6, last updated in 2013, no recent releases (abandoned).

pip install bash==0.6
error ImportError: No module named bash
cause Library not installed or Python 3 incompatible if installed incorrectly.
fix
pip install bash==0.6
error TypeError: 'NoneType' object is not callable
cause Command not found in PATH returns None; trying to call it as a function raises error.
fix
Check that the command exists and is in PATH before calling.
gotcha Arguments are joined with spaces; do not pass untrusted input without quoting. e.g., bash.cat('file.txt') is safe, but bash.grep(f'-e {user_input}') may allow injection.
fix Use shell escaping or prefer subprocess for dynamic commands.
gotcha Set interpreter path via bash.settings.bash='/bin/bash' on systems where bash is elsewhere (e.g., NixOS). Defaults to /bin/bash.
fix import bash; bash.settings.bash='/usr/bin/bash'
deprecated Library is unmaintained since 2013, no Python 3 compatibility fixes. May not work with newer Python versions.
fix Consider alternatives: sh, plumbum, subprocess.

Run bash commands by calling them as functions. Use keyword arguments for flags.

import bash
result = bash.ls('-l')
print(result)