Skip to content

Instantly share code, notes, and snippets.

@prrao87
Forked from ines/.zshrc
Last active December 21, 2023 20:19
Show Gist options
  • Save prrao87/87b3761d58b7ae33c6250795a81d589d to your computer and use it in GitHub Desktop.
Save prrao87/87b3761d58b7ae33c6250795a81d589d to your computer and use it in GitHub Desktop.
Command to activate / create Python virtual environmment
# Do not use the alias `python3`
# For this to work properly, explicitly specify the python version as necessary on your system
function venv {
default_envdir=".venv"
envdir=${1:-$default_envdir}
if [ ! -d $envdir ]; then
python3.12 -m venv $envdir
python3.12 -m pip install ruff
echo -e "\x1b[38;5;2m✔ Created virtualenv $envdir\x1b[0m"
fi
source $envdir/bin/activate
export PYTHONPATH=`pwd`
echo -e "\x1b[38;5;2m✔ Activated virtualenv $envdir\x1b[0m"
python3.12 --version
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment