Skip to content

Instantly share code, notes, and snippets.

@jpramosi
Last active September 5, 2024 12:06
Show Gist options
  • Save jpramosi/28a46c025b3c748a349994fd9971e5cc to your computer and use it in GitHub Desktop.
Save jpramosi/28a46c025b3c748a349994fd9971e5cc to your computer and use it in GitHub Desktop.
Utility bash script to run python in venv.
#!/bin/bash
# pythonx init
# pythonx -m pip install numpy
# pythonx script.py
function on_exit {
deactivate
}
if [ "$1" = "init" ]; then
python3 -m venv .venv
exit 0
fi
trap on_exit EXIT
source .venv/bin/activate && python3 $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment