Skip to content

Instantly share code, notes, and snippets.

@bmmalone
Created March 14, 2020 08:53
Show Gist options
  • Save bmmalone/10c247b108654c42bb6655a6a931dd71 to your computer and use it in GitHub Desktop.
Save bmmalone/10c247b108654c42bb6655a6a931dd71 to your computer and use it in GitHub Desktop.
Automation on top of conda
#! /usr/bin/env bash
function mkipycondaenv {
if [ "$#" -ne 1 ]; then
echo "usage: mkipycondaenv <condaenv_name>"
return 1
fi
conda create --name "$1" pip wheel jupyter ipykernel
conda activate "$1"
python3 -m ipykernel install --user --name "$1" --display-name "$1"
ln -s `which pip` `which pip`3
}
###
# We can use `ipy` to ensure we always use the python instance in the virtual
# environment: https://coderwall.com/p/xdox9a/running-ipython-cleanly-inside-a-virtualenv
###
alias ipy="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
@bmmalone
Copy link
Author

bmmalone commented Mar 14, 2020

Presumably, this function is imported in .bashrc or similar so that the commands are available from a shell using a statement similar to the following.

if [ -f $HOME/local/bin/conda_wrapper.sh ]; then
  source $HOME/local/bin/conda_wrapper.sh
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment