Skip to content

Instantly share code, notes, and snippets.

@mturch
Forked from ruxi/make_conda_env.sh
Created October 21, 2023 15:56

Revisions

  1. @ruxi ruxi created this gist Jul 21, 2016.
    47 changes: 47 additions & 0 deletions make_conda_env.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    %%writefile make_conda_env.sh
    #!/usr/bin/env bash
    # author: github.com/ruxi
    # reproducibly create conda env

    read -p "Create new conda env (y/n)?" CONT

    if [ "$CONT" == "n" ]; then
    echo "exit";
    else
    # user chooses to create conda env
    # prompt user for conda env name
    echo "Creating new conda environment, choose name"
    read input_variable
    echo "Name $input_variable was chosen";

    # Create environment.yml or not
    read -p "Create 'enviroment.yml', will overwrite if exist (y/n)?"
    if [ "$CONT" == "y" ]; then
    # yes: create enviroment.yml
    echo "# BASH: conda env create
    # source activate phd
    name: $input_variable
    dependencies:
    - python=3
    - jupyter
    - notebook
    - numpy
    - rpy2
    - pandas
    - scipy
    - numpy
    - scikit-learn
    - seaborn
    - pip:
    - plotly">environment.yml

    #list name of packages
    conda env create
    else
    echo "installing base packages"
    conda create --name $input_variable\
    python=3 jupyter notebook numpy rpy2\
    pandas scipy numpy scikit-learn seaborn
    fi
    echo "to exit: source deactivate"
    fi