More about conda
The environment and package manager of Anaconda
It is highly recommended to use environments for your work. Environments help to isolate your projects from each other, and to create reproducible setups that can include not only a plethora of Python packages, but also binaries and other dependencies. It is also the easiest way to make sure your code will still work several months or years later while having worked on several other projects in the meantime.
Below is a list of common conda
commands. For a complete overview of all available commands, see: Command Reference.
Create an environment
Note that this environment is entirely empty. It will not even contain a Python installation. As a consequence, starting an interactive Python interpreter from this environment will fall back to the system Python.
It is not a good idea to use the system Python for your work and/or explorations. It is used by your system and should be left alone!
It is therefore a good idea to at least install Python when creating a new environment. So instead of the above, do
The base environment
Whenever you launch a new command line client (Terminal, Anaconda Prompt, ...) the base environment of your Anaconda installation will be active by default. Think of it as the operating system of you anaconda installation. Leave the base environment alone! Always use a separate environment for your work. You can have as many as you like, with as little or as many installed packages and tools as needed.
The active environment is mentioned in parenthesis at the start of the command line, before the "prompt". The prompt is a sequence of one or more characters indicating "readiness to receive commands". Usually it is one of $
, >
, %
, but it can be anything. Therefore your command line will look something like this.
Once you activate an environment, it will be mentioned in parenthesis instead of base
.
Since the prompt symbol can be different on different systems, to avoid confusion, and also just for simplicity, the prompt and whatever comes before are often omitted in command line instructions.
So instead of this
You will see this (unless otherwise mentioned)
Just to make sure it registers: Leave the base environment alone!
Installing packages
Install packages in a specific environment.
Install a package in the active environment (but, remember, not in base
).
Note that conda
packages are made available via channels. conda
doesn't look through all channels automatically. It needs to be told which channels to search for available package releases. Arguable the most important channel is conda-forge
. To install a package from conda-forge
you can specify it via the -c
or --channel
option.
To permanently add conda-forge
to the list of channels where conda
looks for packages, do
Remove an environment
Note that you can't remove the current environment. Therefore, before removing an environment you must deactivate it.
Alternatively, you can simply remove all packages from an environment.
Other commands
List all available environments.
List all installed packages in the active environment.
List all COMPAS packages in the active environment.
List all COMPAS packages in a specific environment.
Last updated