Conda Guide: How to Manage Multiple Python Versions and Environments
Learn how to use Conda for Python environment management. This guide covers Conda vs pip, Anaconda vs Miniconda, creating and managing environments, essential commands, and best practices for juggling multiple Python versions.
PythonCondaAnacondaMinicondaEnvironment ManagementVersion Control
1532  Words
2020-01-11
If you have ever worked on one project that requires Python 2.7 and another that needs Python 3.10, you know how painful version conflicts can be. Conda solves this problem once and for all. This guide walks you through everything you need to know about Conda — from installation to daily workflow.
What Is Conda?
Conda is an open-source package manager and environment manager. It was originally built for Python, but it actually supports any language. Its core capabilities include:
- Package management — install, update, and remove software packages
- Dependency resolution — automatically handle inter-package dependencies
- Environment isolation — create fully independent development environments
- Cross-platform — works on Windows, macOS, and Linux
Think of it this way: Conda = pip (package management) + virtualenv (virtual environments) + non-Python dependency management
Conda vs pip: Which Should You Use?
| Feature | pip | Conda |
|---|---|---|
| Purpose | Python package installer | General-purpose package and environment manager |
| Scope | Python packages only | Python packages + other languages (e.g., C/C++ libraries) |
| Package source | PyPI | Anaconda repository / conda-forge |
| Package format | Wheels / source distributions | Pre-compiled binaries |
| Dependency handling | Installs serially; conflicts possible | SAT solver checks all dependencies globally |
| Environment management | Requires virtualenv / venv | Built-in |
| Python interpreter | Must be pre-installed | Can install any Python version directly |
When to use what:
- Data science or ML projects → Conda (complex native dependencies)
- Pure Python web development → pip + venv is usually enough
- Need to switch between multiple Python versions → Conda is more convenient
- A package only exists on PyPI → use pip inside a Conda environment
Anaconda vs Miniconda: How to Choose
Anaconda: The Batteries-Included Distribution
Anaconda is the full-size Conda distribution:
- 250+ pre-installed packages: NumPy, Pandas, Matplotlib, Scikit-learn, Jupyter, and more
- Graphical interface: Anaconda Navigator for visual environment and package management
- Download size: roughly 500 MB – 3 GB
Best for:
- Python / data science beginners
- Anyone who wants a ready-to-go analytics environment
- Users who prefer a GUI
Miniconda: The Minimal Install
Miniconda is the stripped-down Conda distribution:
- Only the essentials: Conda + Python + a handful of dependencies
- Download size: about 50 MB
- Purely command-line driven
Best for:
- Developers comfortable with the terminal
- Custom environment setups
- Server deployments (save disk space)
- Anyone who wants full control over installed packages
Quick Comparison
| Scenario | Recommendation |
|---|---|
| Just getting started | Anaconda |
| Personal machine with plenty of storage | Anaconda |
| Server or CI deployment | Miniconda |
| Only need a few specific packages | Miniconda |
| Want full control over the environment | Miniconda |
Commercial use note: Anaconda requires a paid license for organizations with more than 200 employees. To avoid licensing issues, use Miniconda with the conda-forge channel instead.
Installing Conda
Option 1: Install Miniconda (Recommended)
macOS / Linux
# Download the installer (macOS Apple Silicon)
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
# Download the installer (Linux x86_64)
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
# Run the installer
bash Miniconda3-latest-*.sh
# Follow the prompts — say yes when asked to initialize Conda
After installation, restart your terminal or run:
source ~/.bashrc # Bash
source ~/.zshrc # Zsh
Windows
- Download the Miniconda Windows installer
- Double-click the installer and follow the wizard
- Check “Add Miniconda to PATH” when prompted
Option 2: Install Anaconda
Visit the Anaconda website, download the installer for your OS, and follow the setup wizard.
Verify the Installation
conda --version
# Example output: conda 24.x.x
conda info
# Displays detailed Conda configuration
Environment Management: The Core Skill
Creating Environments
# Create an environment named myenv with a specific Python version
conda create -n myenv python=3.10
# Create an environment with packages pre-installed
conda create -n datascience python=3.11 numpy pandas jupyter
# Clone an existing environment
conda create -n myenv_copy --clone myenv
Activating and Deactivating
# Activate an environment
conda activate myenv
# Deactivate and return to base
conda deactivate
# Switch directly to a different environment
conda activate another_env
Once activated, your shell prompt shows the environment name, e.g.,
(myenv) $
Listing Environments
# List all environments
conda env list
# or
conda info --envs
# Example output:
# base * /Users/bruce/miniconda3
# myenv /Users/bruce/miniconda3/envs/myenv
# datascience /Users/bruce/miniconda3/envs/datascience
Removing Environments
# Remove an environment and all its packages
conda remove -n myenv --all
# Verify it's gone
conda env list
Exporting and Importing Environments
This is invaluable for team collaboration and machine migration:
# Export the current environment to a YAML file
conda activate myenv
conda env export > environment.yml
# Recreate an environment from a YAML file
conda env create -f environment.yml
# Update an existing environment from a YAML file
conda env update -f environment.yml
Example environment.yml:
name: myenv
channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- numpy=1.24
- pandas>=2.0
- pip
- pip:
- requests
- beautifulsoup4
Package Management: Daily Operations
Searching for Packages
# Search for a package
conda search numpy
# Show detailed package info
conda search numpy --info
Installing Packages
# Install into the current environment
conda install numpy
# Install a specific version
conda install numpy=1.24.0
# Install multiple packages at once
conda install numpy pandas matplotlib
# Install from a specific channel
conda install -c conda-forge pytorch
# Install into a named environment without activating it
conda install -n myenv numpy
Updating Packages
# Update a specific package
conda update numpy
# Update all packages in the current environment
conda update --all
# Update Conda itself
conda update conda
Removing Packages
# Remove a package
conda remove numpy
# Remove from a specific environment
conda remove -n myenv numpy
Listing Installed Packages
# List everything in the current environment
conda list
# Filter for a specific package
conda list | grep numpy
# Export the package list
conda list --export > packages.txt
Configuration Tips
Add conda-forge as the Default Channel
The community-driven conda-forge channel is often more up-to-date than the default Anaconda channel:
# Add conda-forge with highest priority
conda config --add channels conda-forge
# Always show channel URLs (useful for debugging)
conda config --set show_channel_urls yes
# Check current channel configuration
conda config --show channels
You can also edit ~/.condarc directly:
channels:
- conda-forge
- defaults
show_channel_urls: true
Other Useful Settings
# Don't activate the base environment on shell startup (recommended)
conda config --set auto_activate_base false
# Set a custom path for environments (optional)
conda config --add envs_dirs /path/to/custom/envs
# Free up disk space by clearing cached packages
conda clean --all
Practical Example: Switching Between Python Versions
Suppose you maintain projects that target both Python 2.7 and Python 3.10:
# Create a Python 2.7 environment (note: Python 2 is end-of-life)
conda create -n py27 python=2.7
# Create a Python 3.10 environment
conda create -n py310 python=3.10
# Switch to Python 2.7
conda activate py27
python --version # Python 2.7.18
# Switch to Python 3.10
conda activate py310
python --version # Python 3.10.x
# Check which Python binary is active
which python
Mixing Conda and pip
Some packages are only available on PyPI. Here is the recommended way to use pip inside a Conda environment:
# 1. Install as much as you can with Conda first
conda install numpy pandas scikit-learn
# 2. Use pip for packages not in Conda channels
pip install some-pypi-only-package
# 3. Export the full environment (includes pip packages)
conda env export > environment.yml
Important: Avoid installing the same package with both
conda installandpip install— this can lead to version conflicts and broken environments.
Command Cheat Sheet
| Task | Command |
|---|---|
| Check Conda version | conda --version |
| Show configuration | conda info |
| Create environment | conda create -n ENV python=3.10 |
| Activate environment | conda activate ENV |
| Deactivate environment | conda deactivate |
| List all environments | conda env list |
| Remove environment | conda remove -n ENV --all |
| Export environment | conda env export > env.yml |
| Import environment | conda env create -f env.yml |
| Install package | conda install PACKAGE |
| Update package | conda update PACKAGE |
| Remove package | conda remove PACKAGE |
| List installed packages | conda list |
| Search for package | conda search PACKAGE |
| Clear cache | conda clean --all |
Troubleshooting
Conda Is Slow
- Use conda-forge as your primary channel (see the Configuration section above)
- Try Mamba, a drop-in replacement for Conda with much faster dependency solving:
conda install -c conda-forge mamba
mamba install numpy # Same syntax, up to 10x faster
Dependency Conflicts
# Preview what would change without actually installing
conda install package --dry-run
# When in doubt, start with a fresh environment
conda create -n fresh_env python=3.10 package1 package2
conda activate Does Not Work
Make sure Conda’s shell integration is set up:
conda init bash # or zsh / fish / powershell
# Then restart your terminal
Reclaiming Disk Space
# Remove cached packages and index files
conda clean --all
# Delete environments you no longer use
conda remove -n old_env --all
Summary
Conda is the go-to tool for managing multiple Python versions and isolated environments. Here are the key takeaways:
- Conda vs pip — Conda shines for data science projects and multi-version Python management
- Anaconda vs Miniconda — beginners benefit from Anaconda; experienced developers prefer Miniconda
- Environment management —
create,activate, andexportare your most-used commands - Channel configuration — adding conda-forge gives you access to a larger, more current package catalog
- Mixing pip — always install Conda packages first, then fill gaps with pip
For more tips on building an efficient terminal workflow, check out the Oh My Zsh configuration guide.
Comments
Join the discussion — requires a GitHub account