|
| 1 | +# Using Conda/Mamba |
| 2 | + |
| 3 | +Conda is an open-source Python package and environment management tool. Mamba is a `C++` implementation of Conda: it has the same command syntax but is supposed to be more efficient. We will use it to control our Python environment. To initialise: |
| 4 | + |
| 5 | +1. Configure your `.bash_profile` using any text editor (such as `emacs` or `vim`): |
| 6 | + |
| 7 | + ```bash |
| 8 | + # Add to ~/.bash_profile |
| 9 | + if [ -f ~/.bashrc ]; then |
| 10 | + . ~/.bashrc |
| 11 | + fi |
| 12 | + ``` |
| 13 | + |
| 14 | +2. Initialise Mamba: |
| 15 | + |
| 16 | + ```bash |
| 17 | + mamba init |
| 18 | + ``` |
| 19 | + |
| 20 | +Ensure that you either start a new shell after initialisation, or run |
| 21 | + |
| 22 | +```bash |
| 23 | +source ~/.bashrc |
| 24 | +``` |
| 25 | + |
| 26 | +## Basic Conda/Mamba commands |
| 27 | + |
| 28 | +Below is a list of basic Conda/Mamba commands. You should **not** need to use most of these. |
| 29 | + |
| 30 | +### Environment management |
| 31 | + |
| 32 | +```bash |
| 33 | +# Activate an environment |
| 34 | +mamba activate myenv |
| 35 | + |
| 36 | +# Deactivate current environment |
| 37 | +mamba deactivate |
| 38 | + |
| 39 | +# List all environments |
| 40 | +mamba env list |
| 41 | + |
| 42 | +# Remove a environment by name |
| 43 | +mamba env remove -n myenv |
| 44 | + |
| 45 | +# Export environment to YAML file |
| 46 | +mamba env export > env.yml |
| 47 | + |
| 48 | +# Create environment from YAML file |
| 49 | +mamba env create -f env.yml |
| 50 | + |
| 51 | +# Create a new named environment |
| 52 | +mamba create -n myenv |
| 53 | + |
| 54 | +``` |
| 55 | +### Package management |
| 56 | + |
| 57 | +```bash |
| 58 | +# Install a package |
| 59 | +mamba install package_name |
| 60 | + |
| 61 | +# Install multiple packages |
| 62 | +mamba install package1 package2 |
| 63 | + |
| 64 | +# Remove a package |
| 65 | +mamba remove package_name |
| 66 | + |
| 67 | +# Update a specific package |
| 68 | +mamba update package_name |
| 69 | + |
| 70 | +# Update all packages |
| 71 | +mamba update --all |
| 72 | + |
| 73 | +# List installed packages |
| 74 | +mamba list |
| 75 | + |
| 76 | +# Search for a package |
| 77 | +mamba search package_name |
| 78 | +``` |
| 79 | + |
| 80 | +### General |
| 81 | + |
| 82 | +```bash |
| 83 | +# Initialise Mamba |
| 84 | +mamba init |
| 85 | + |
| 86 | +# Clean cache (downloaded packages) |
| 87 | +mamba clean |
| 88 | + |
| 89 | +# Display Mamba system information |
| 90 | +mamba info |
| 91 | +``` |
| 92 | + |
| 93 | +## Navigation |
| 94 | + |
| 95 | +- Previous: [Navigating JupyterHub](04-JupyterHub.md) |
| 96 | +- Next: [The Mu2e Python Environment](06-TheMu2eEnvironment.md) |
| 97 | +- [Back to Main](../README.md) |
0 commit comments