Managing Anaconda Virtual Environments

Installation and Setup

Miniconda installers for different Python versions are available at: https://repo.anaconda.com/miniconda/

For example, to install Miniconda with Python 3.7 on Windows:

https://repo.anaconda.com/miniconda/Miniconda3-py37_23.1.0-1-Windows-x86_64.exeAfter installation, you may need to manually configure anvironment variables. Navigate to System Properties > Advanced > Environment Variables, and add the Miniconda paths to the system Path variable.

Verify installation by opening command prompt and running:

conda info

Environment Management

Create a new virtual environment with specific Python version:

conda create --name ml_env python=3.11

Activate the enviroment:

conda activate ml_env

Exit the current environment:

conda deactivate

List all available environments:

conda env list
# or
conda info --envs

Remove an environment completely:

conda remove --name ml_env --all

Clone an existing environment:

conda create --name new_env --clone source_env

Package Management

Install packages using pip or conda:

pip install numpy
conda install scipy

Install specific package versions:

pip install opencv-python==3.4.2.16
pip install opencv-contrib-python==3.4.2.16

Install multiple packages from requirements file:

pip install -r requirements.txt

List installed packages in current environment:

conda list

Install packages in a specific environment:

conda install -n target_env package_name

Create environment with specific packages:

conda create --name data_env pandas matplotlib seaborn

Configuration and Optimization

Add mirror channels for faster downloads:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes

Set download timeout for slow connections:

conda config --set remote_read_timeout_secs 600.0

Install packages offline:

conda install --offline ./package.tar.bz2

Environment Sharing

Export environment configuration:

conda activate target_env
conda env export > environment.yml

Recreate environment from YAML file:

conda env create -f environment.yml

Maintenance

Update conda and Anaconda:

conda update conda
conda update anaconda

Update specific packages:

conda update numpy

Remove packages:

conda remove package_name

Tags: anaconda conda python virtual-environment package-management

Posted on Sat, 16 May 2026 15:15:01 +0000 by OldWolf