Conda is a powerful package manager and environment management system for Python and other languages. It helps install, update, and manage packages while handling dependencies automatically.
1. Why Use Conda?
✅ Manages Dependencies – Resolves and installs packages efficiently.
✅ Cross-Language Support – Works with Python, R, C, C++, and more.
✅ Virtual Environment Management – Creates isolated environments for projects.
✅ Works Without PyPI – Uses Anaconda and Conda-Forge repositories.
2. Installing Conda
2.1 Install Anaconda (Full Distribution, Includes Conda)
Download and install Anaconda from:
🔗 https://www.anaconda.com/download
2.2 Install Miniconda (Lightweight Conda)
For a minimal version, install Miniconda:
🔗 https://docs.conda.io/en/latest/miniconda.html
2.3 Verify Installation
Check if Conda is installed:
conda --version
Example Output:
conda 23.1.0
3. Conda vs. Pip
Feature | Conda | Pip |
---|---|---|
Package Manager | Yes | No (Only installs packages) |
Manages Environments | Yes | No |
Dependency Resolution | Better | Limited |
Sources | Anaconda, Conda-Forge | PyPI |
🔹 Use Conda for managing environments and complex dependencies.
🔹 Use Pip when installing PyPI packages inside a Conda environment.
4. Managing Conda Environments
4.1 Create a New Environment
conda create --name my_env python=3.10
This creates an environment called my_env
with Python 3.10.
4.2 Activate an Environment
conda activate my_env
4.3 Deactivate an Environment
conda deactivate
4.4 List All Environments
conda env list
4.5 Remove an Environment
conda remove --name my_env --all
5. Managing Packages with Conda
5.1 Install a Package
conda install numpy
5.2 Install a Package from Conda-Forge
conda install -c conda-forge pandas
5.3 List Installed Packages
conda list
5.4 Update a Package
conda update numpy
5.5 Remove a Package
conda remove numpy
5.6 Install Packages with Pip Inside Conda
pip install requests
Use pip
only after installing required Conda packages to avoid dependency conflicts.
6. Exporting and Cloning Environments
6.1 Export an Environment to a YAML File
shCopyEditconda env export > environment.yml
6.2 Create an Environment from a YAML File
conda env create -f environment.yml
6.3 Clone an Environment
conda create --name new_env --clone my_env
7. Removing Conda and Uninstalling Packages
7.1 Remove a Specific Package
conda remove pandas
7.2 Remove Conda Completely (Linux/Mac)
rm -rf ~/miniconda3 # or anaconda3
7.3 Remove Conda from Windows
Uninstall from Control Panel > Programs.
8. Summary of Conda Commands
Command | Description |
---|---|
conda create --name my_env python=3.10 | Create a new environment |
conda activate my_env | Activate an environment |
conda deactivate | Deactivate an environment |
conda env list | List all environments |
conda install numpy | Install a package |
conda list | List installed packages |
conda update numpy | Update a package |
conda remove numpy | Remove a package |
conda env export > environment.yml | Export environment to YAML |
conda env create -f environment.yml | Create environment from YAML |