conda is a package manager for Python and R intended for use with scientific computing applications, like data science and machine learning. It comes in two different distributions: Anaconda and Miniconda. The core idea with Anaconda is that it simplifies package management by creating closed environments that isolates packages as necessary.
What's the base environment?
conda itself is installed in
base
. For each project we do, we want to create separate environments frombase
. If we create multiple environments with the same packages, this is fine — each packages will hard-link them to save space.
Some quick notes:
- If Anaconda’s giving a “Multiple errors encountered” message when trying to install any packages, reopen it in administrator mode and try again.
- I don’t seem to be running into this problem with Miniconda, so this seems to be a full Anaconda problem.
- If conda is stuck at “Solving environment” during package installation (GUI and CLI), follow the steps at this StackOverflow post.
- Anaconda is slow as shit, especially when installing packages. The full distribution is really bloated, so a better choice is to use Mamba or Miniconda for most practical purposes.
- It’s also possible to downgrade the version of Python inside the CLI. Use
conda install python=3.xx
. Same goes for most packages.
CLI commands
Assume commands are prefixed with conda
.
Core package commands:
install
: installs into the specified environmentsearch
: for a given packagelist
: list packages-e > requirements.txt
: output to a requirements.txt file
info
--envs
: gives us the number of conda environments on the machine.
For environment setup:
activate NAME
: activate a given environment in the shelldeactivate
: deactivate the current working environmentcreate --name NAME python=3.xx
: create a named environment with a specific version of Pythonremove
: environment deletion command--all
: remove all packages and the environment itself--keep-env
: used with--all
, deletes all packages but keeps the environment-n NAME
: delete a specific named environment