Get started with Conda
Anaconda is a distribution of Python with extra high quality packages, Miniconda is a mini version of Anaconda with base packages. Conda is a package management system and environment management system. It is recommemded to use conda and create an environment for each project, you don’t have to install Python first, just install Anaconda directly.
Conda as a package manager
Get started
- Verify conda is installed, check version number
conda --version
- Check basic information about conda
conda info
- Search for a package
conda search beautifulsoup4
- Install a package
conda install beautifulsoup4
conda install python=3.7
- Update a package
conda update beautifulsoup4
conda update python
- Remove a package
conda remove beautifulsoup4
- Update conda to the current version
conda update conda
- Keep Anaconda up to date
conda update anaconda
conda update --all
- List installed packages
conda list
Advanced topics
- Install a package from a specific channel
conda install scipy --channel conda-forge
Option -c
means --channel
conda install -c anaconda anaconda-navigator
conda install conda-forge::PKGNAME
- Update conda itself
Option -n
means --name
conda update -n base conda
conda update -n base -c defaults conda
- Detailed information about package versions
conda search PKGNAME --info
- Remove unused cached files including unused packages
conda clean --all
- Remove a package from an environment
conda uninstall PKGNAME --name ENVNAME
- Update all packages within an environment
conda update --all --name ENVNAME
- Examine Conda configuration and configuration services
conda config --show conda config --show-sources
- Got an SSL error…
conda config --set ssl_verify false conda update requests conda config --set ssl_verify true
Conda as an environment manager
Get started
- Create a virtual environment
conda create --name my_env
conda create --name py37 python=3.7
- Activate an environment
conda activate my_env
- Deactivate current environment
conda deactivate
- Remove an environment
conda remove --name my_env
- Export an environment to a file
conda env export > requirements.txt
conda env export --name my_env > my_env.yml
- Create an environment from a file
conda env create --file my_env.yml
Option
-f
means--file
conda env create -f requirements.txt
- List all environments
conda env list
conda info --envs
Advanced topics
- Export an environment with exact package versions
conda list --explicit > pkgs.txt
Option
-e
means--explicit
conda list -e > pkgs.txt
- Create an environment based on exact package versions
conda create --name NEWENV --file pkgs.txt
- Make an exact copy of an environment
conda create --clone ENVNAME --name NEWENV
Written on November 19, 2019