-
-
Save GarrettMooney/e56ad31df72358290a07e7b9c53618c3 to your computer and use it in GitHub Desktop.
Command to activate / create Python virtual environmment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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