virtual environment setup
Upgrade pip.
python3 -m pip install --upgrade pipCreate a base folder to store the virtual environments in.
mkdir ~/.venvCreate a new virtual environment.
python3 -m venv ~/.venv/venvActivate the virtual environment.
source ~/.venv/venv/bin/activateInstall ipykernel.
python3 -m pip install ipykernelAdd the new kernel.
ipython kernel install --name=venv #--userTL;DR
python3 -m pip install --upgrade pip
mkdir ~/.venv
python3 -m venv ~/.venv/venv
source ~/.venv/venv/bin/activate
python3 -m pip install ipykernel
ipython kernel install --name=venv #--useralias setup
Add the following aliases to your .bashrc or .zshrc file:
Activate your virtual environment and start jupyter notebook.
alias jn='source ~/.venv/venv/bin/activate && jupyter notebook'Activate your virtual environment.
alias letsgo='source ~/.venv/venv/bin/activate'Activate any of your virtual environments.
function act { source ~/.virtualenvs/"$1"/bin/activate }> act venvThe standard zsh shell that comes with macOS doesn’t print the current active virtual environment. Add the following to ~/.zshrc to enable showing the virtual environment.
export VIRTUAL_ENV_DISABLE_PROMPT=Activate the virtual environment by default.
if [[ "$VIRTUAL_ENV" != "/Users/fabian/.venv/venv" ]]; then source ~/.venv/venv/bin/activate; fiSet default directory to ~/Code.
if [[ $PWD == $HOME ]]; then cd /Users/fabian/Code; fiTL;DR
alias jn='source ~/.venv/venv/bin/activate && jupyter notebook'
alias letsgo='source ~/.venv/venv/bin/activate'
alias typora="open -a typora"
alias cm="git add . && git commit -am "Update" && git push"
function act { source ~/.venv/"$1"/bin/activate }
export VIRTUAL_ENV_DISABLE_PROMPT=
if [[ "$VIRTUAL_ENV" != "/Users/fabian/.venv/venv" ]]; then source ~/.venv/venv/bin/activate; fi
if [[ $PWD == $HOME ]]; then cd /Users/fabian/Code; fi