Skip to content

Instantly share code, notes, and snippets.

@mathomp4
Last active February 14, 2025 18:52
Show Gist options
  • Save mathomp4/dd83b8c43f3259d1cc769f498dfb3674 to your computer and use it in GitHub Desktop.
Save mathomp4/dd83b8c43f3259d1cc769f498dfb3674 to your computer and use it in GitHub Desktop.
Using Miniforge to make a Python stack

Making a Python stack with Miniforge

In the examples below, I'll mainly be using Discover at NCCS as my guide for paths, etc., but it can be genericized

Preliminary Setup

You want to make sure mamba, et al, do no cache files in your home dir as that can kill quota.

So:

mkdir -p $NOBACKUP/mamba-cache
export MAMBA_ROOT_PREFIX=$NOBACKUP/mamba-cache

and you might as well put MAMBA_ROOT_PREFIX in your .bashrc for convenience.

Installing the base miniforge

In the steps below, I'm using paths with my username, so of course change these

mkdir -p /discover/nobackup/mathomp4/Miniforge/TestpyD
cd /discover/nobackup/mathomp4/Miniforge/TestpyD
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh -b -p /discover/nobackup/mathomp4/Miniforge/TestpyD/install

Create an environment

That gets the base. Now we make an environment and install there:

/discover/nobackup/mathomp4/Miniforge/TestpyD/install/bin/mamba create -y \
   -p /discover/nobackup/mathomp4/Miniforge/TestpyD/install/envs/py3.12 python=3.12
/discover/nobackup/mathomp4/Miniforge/TestpyD/install/bin/mamba install -y -n py3.12 ipykernel

Just use that last command over and over to install stuff.

/discover/nobackup/mathomp4/Miniforge/TestpyD/install/bin/mamba install -y -n py3.12 numpy scipy ...

Register the stack with Jupyter

/discover/nobackup/mathomp4/Miniforge/TestpyD/install/envs/py3.12/bin/python3 -m ipykernel install --user --name py3.12 --display-name "Python 3.12"

You can call it whatever you like.

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