Useful Anaconda commands

Useful Anaconda commands

Create environment

If you’re juggling multiple projects like I am, keeping your packages and dependencies from colliding is key. Anaconda environments let you compartmentalize your projects to keep everything neat. Here’s how you spin up a new environment:

conda create --name myenv

You can also specify Python versions if you need to:

conda create --name myenv python=3.8

Install a new package

Once your environment’s up, adding packages is a breeze. Here’s a classic:

conda install numpy

You can specify the environment with the --name flag or just activate the env before running install. And for those version-specific needs:

conda install numpy=1.18.1

Get a list of all my environments

Lost track of all the environments you’ve spun up? To see a list of all your Anaconda environments:

conda env list

Or if you’re into brevity, conda info --envs works too.

Create a new environment variable

Environment variables in Anaconda can be super helpful for maintaining paths and settings across sessions. Setting up a new one is easy:

conda env config vars set MY_VAR=my_value

This example sets MY_VAR to 'my_value'. Swap in whatever key-value pair you need. Restart the env to see the changes by deactivating and reactivating it.

conda activate myenv conda deactivate