Virtual environments
mamba lets you install Python packages for a class or project without affecting other people.
Create an environment
- Log in to a lab or compute machine.
- Create an environment (pick any short name instead of
myproject):
mamba create -n myproject python=3.12 pandasType y if it asks to confirm.
It may take a minute or two to create your new environment, depending on what packages you install and whether they are already cached. If it prints Linking ..., it may pause briefly with little new output while it finishes setting up files on shared scratch.
- Turn the environment on:
mamba activate myprojectYour prompt should show (myproject). Now python uses the packages in that environment.
- When you are done:
mamba deactivateDay-to-day use
mamba activate myproject # start working
python your_script.py
mamba install numpy # add a package (while activated)
mamba deactivate # stop working
mamba env list # see your environmentsCreating an environment takes the longest. Activating and using it later is fast. The same environment works on other lab/compute machines after it exists.
Where your environments live
Environments are stored under your scratch space, not your home directory:
/home/scratch/YOUR_USERNAME/mamba/envs/That is why they follow you from one lab/compute machine to another.