Skip to content

Instantly share code, notes, and snippets.

@GarrettMooney
Forked from ines/.zshrc
Last active November 12, 2020 18:16
Show Gist options
  • Save GarrettMooney/e56ad31df72358290a07e7b9c53618c3 to your computer and use it in GitHub Desktop.
Save GarrettMooney/e56ad31df72358290a07e7b9c53618c3 to your computer and use it in GitHub Desktop.
Command to activate / create Python virtual environmment
# venv
# usage:
# $ venv .recsys
function venv {
default_envdir=".env"
envdir=${1:-$default_envdir}
if [ ! -d $envdir ]; then
python3.7 -m virtualenv -p python3.7 $envdir
echo -e "\x1b[38;5;2m✔ Created virtualenv $envdir\x1b[0m"
source $envdir/bin/activate
echo -e "\x1b[38;5;2m✔ Activated virtualenv $envdir\x1b[0m"
pip install ipython ipykernel jupyter jupyterlab black flake8
echo -e "\x1b[38;5;2m✔ Installed packages \x1b[0m"
python -m ipykernel install --user --name=$envdir --display-name="Python 3.7 ($envdir)"
echo -e "\x1b[38;5;2m✔ Created kernel 'Python3.7 ($envdir)'\x1b[0m"
export PYTHONPATH=$(pwd)
fi
if [ -d $envdir ]; then
source $envdir/bin/activate
echo -e "\x1b[38;5;2m✔ Activated virtualenv $envdir\x1b[0m"
export PYTHONPATH=$(pwd)
fi
python --version
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment