Conda Installation and Usage Guide — The Standard for Python Environment Management

Why You Need Conda

Different Python projects require different library versions. If Project A needs numpy 1.24 and Project B requires numpy 2.0, a conflict arises. Conda solves this problem by creating independent environments for each project.

Differences from pip + venv:

Aspectpip + venvConda
Python version managementRequires separate tools (pyenv, etc.)Managed directly by Conda
Non-Python packagesCannot install (system-dependent)Includes C libraries, CUDA, etc.
Dependency resolutionPossible conflicts depending on install orderValidates compatibility via SAT solver
Use casePure Python projectsData science, ML, scientific computing

Conda is recommended for data science or machine learning projects. For pure web development, pip + venv is sufficient.

Miniconda vs Anaconda

AspectMinicondaAnaconda
Size~80MB~4.5GB
Included packagesconda + Python onlyconda + 300+ packages
Recommended forDevelopers who want to install only what they needBeginners who want pandas, numpy, etc. immediately

Miniconda is recommended. Installing only the packages you need saves significant disk space and keeps your environment clean.

Installation

Windows

# 1. Download the Miniconda installer
# Download Windows 64-bit from https://docs.conda.io/en/latest/miniconda.html

# 2. Run the installer — do NOT check "Add to PATH" (recommended)
# → Use "Anaconda Prompt" or "Miniconda Prompt" instead

# 3. Verify installation (in Anaconda Prompt)
conda --version
# conda 24.9.2

python --version
# Python 3.12.7

macOS / Linux

# 1. Download and run the install script
# macOS (Apple Silicon)
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
bash Miniconda3-latest-MacOSX-arm64.sh

# macOS (Intel)
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh

# Linux
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

# 2. Restart your shell or apply the config
source ~/.bashrc    # bash
source ~/.zshrc     # zsh

# 3. Verify installation
conda --version
# conda 24.9.2

During installation, select yes when asked “Do you wish to update your shell profile to automatically initialize conda?” This activates conda automatically every time you open a terminal.

Virtual Environment Management

Creating an Environment

# Create a new environment with Python 3.12
conda create -n myproject python=3.12
# Proceed ([y]/n)? y

# Activate the environment
conda activate myproject
# (myproject) $    <- Environment name shown in prompt

# Check Python version
python --version
# Python 3.12.7

# Deactivate the environment
conda deactivate

-n specifies the environment name. Use meaningful names per project (e.g., ml-project, web-api, data-analysis).

Listing and Removing Environments

# List all environments
conda env list
# base                  *  /home/user/miniconda3
# myproject                /home/user/miniconda3/envs/myproject
# ml-project               /home/user/miniconda3/envs/ml-project

# Remove an environment
conda env remove -n myproject

# Clone an environment (create a new one based on an existing one)
conda create -n myproject-v2 --clone myproject

Exporting and Reproducing Environments

Use this to reproduce the same environment on a teammate’s machine or a server.

# Export the environment to a YAML file
conda activate myproject
conda env export > environment.yml

# Create an environment from a YAML file (on another machine)
conda env create -f environment.yml

# Cross-platform version (excludes OS-dependent build numbers)
conda env export --no-builds > environment.yml

environment.yml example:

name: myproject
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.12
  - numpy=2.1
  - pandas=2.2
  - scikit-learn=1.5
  - pip:
      - fastapi==0.115.0     # pip-only packages can also be included
      - uvicorn==0.32.0

Package Management

conda install

# Install packages
conda install numpy pandas matplotlib

# Install a specific version
conda install numpy=2.1

# Install from the conda-forge channel (gets newer versions sooner)
conda install -c conda-forge jupyterlab

# List installed packages
conda list
# Name            Version    Channel
# numpy           2.1.3      conda-forge
# pandas          2.2.3      conda-forge
# python          3.12.7     conda-forge

# Search for a package
conda search pytorch

# Remove a package
conda remove matplotlib

The conda-forge Channel

conda-forge offers more packages and faster updates than the default defaults channel. Setting it as the default channel is convenient.

# Set conda-forge as the default channel
conda config --add channels conda-forge
conda config --set channel_priority strict

# Verify settings
conda config --show channels
# channels:
#   - conda-forge
#   - defaults

Mixing conda and pip

Packages not available in Conda can be installed with pip. However, the order matters.

# Correct order: conda first -> pip later
conda install numpy pandas scikit-learn    # Install what's available via conda first
pip install some-rare-package              # Use pip only for what conda doesn't have

# Wrong order: installing with pip first then running conda install
# -> conda may not recognize pip-installed packages, causing conflicts

Common Commands Reference

CommandDescription
conda create -n NAME python=VERSIONCreate a new environment
conda activate NAMEActivate an environment
conda deactivateDeactivate an environment
conda env listList environments
conda env remove -n NAMERemove an environment
conda install PACKAGEInstall a package
conda listList installed packages
conda update condaUpdate conda itself
conda update --allUpdate all packages in the environment
conda env export > environment.ymlExport an environment
conda env create -f environment.ymlReproduce an environment
conda clean --allClean cache/unused packages (saves disk space)

Practical Tips

Do not install packages in the base environment. The base environment is for managing conda itself. Always create a new environment for your work.

# Disable auto-activation of the base environment (optional)
conda config --set auto_activate_base false
# -> The (base) indicator disappears when you open a terminal
# -> Manually activate with conda activate base when needed

If your environment feels slow, run conda clean to clear the cache. You can recover several GB of space.

# Clean all caches, unused packages, and tarballs
conda clean --all
# Total:  3.2 GB
# Proceed ([y]/n)? y

The libmamba solver significantly speeds up dependency resolution. It has been the default solver since Conda 23.10, but if you are on an earlier version, set it manually.

# Check solver
conda config --show solver
# solver: libmamba    <- Already set, you're good

Was this article helpful?