Skip to main content

Conda Environment Management Guide

This tutorial will guide you through installing and configuring Conda, and learning how to use it to manage Python environments and package dependencies.

Conda Overview

What is Conda?

Conda is an open-source package management and environment management system, mainly used for managing Python packages but also supporting other languages. It can:

  • Create isolated Python environments
  • Manage package dependencies
  • Easily switch between environments required by different projects
  • Resolve package version conflicts

Why Choose Conda?

Advantages of Conda
  1. Environment isolation: Each project can have an independent Python environment
  2. Dependency management: Automatically resolves package dependency conflicts
  3. Cross-platform: Supports Windows, macOS, and Linux
  4. Rich packages: Includes packages for scientific computing, machine learning, and other fields
  5. Easy to use: Command-line operations are simple and intuitive

Installing Conda

Choosing an Installation Version

Conda is a lightweight package management and environment management system. We recommend installing Miniconda:

  • Small size: About 400 MB
  • Included content: Conda + Python + base packages
  • Advantages: Fast installation, and you can install specific packages as needed

Downloading Conda

Download Miniconda

  1. Visit the Conda official download page
  2. Select the Miniconda column
  3. Choose the version suitable for your system:
    • Linux: Miniconda3-latest-Linux-x86_64.sh
    • macOS Intel: Miniconda3-latest-MacOSX-x86_64.sh
    • macOS Apple Silicon (M1/M2/M3): Miniconda3-latest-MacOSX-arm64.sh
    • Windows: Miniconda3-latest-Windows-x86_64.exe

Installing Conda

Linux Installation

# Download the installation script
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

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

# Run the installation script
bash Miniconda3-latest-Linux-x86_64.sh

# Follow the prompts to complete the installation
# 1. Read the license agreement and type 'yes' to agree
# 2. Choose the installation path (the default is fine)
# 3. Choose whether to initialize conda (recommended to choose 'yes')

macOS Installation

Method 1: GUI installation (recommended)

Use the uname -m command in the command line to find out your architecture version

  1. Download the .pkg file for your version
  2. Follow the installation wizard to complete the installation
  3. Select Add Miniconda3 to my PATH environment variable (recommended)

Method 2: Command-line installation

If you choose the command-line installation method, you need to download the installation script first:

# Intel chip Mac - download the installation script
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh

# Apple Silicon (M1/M2/M3) Mac - download the installation script
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh

# Run the installation script
bash Miniconda3-latest-MacOSX-x86_64.sh # Intel chip
# Or
bash Miniconda3-latest-MacOSX-arm64.sh # Apple Silicon

# Follow the prompts to complete the installation
# 1. Read the license agreement and type 'yes' to agree
# 2. Choose the installation path (the default is fine)
# 3. Choose whether to initialize conda (recommended to choose 'yes')

Configuring environment variables (important step on macOS)

After installation, you need to add Conda to the system PATH:

# For Zsh users (macOS Catalina and above use Zsh by default)
echo 'export PATH="$HOME/miniconda3/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

# For Bash users
echo 'export PATH="$HOME/miniconda3/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Windows Installation

  1. Double-click the downloaded .exe file
  2. Follow the installation wizard to complete the installation
  3. Select Add Miniconda3 to my PATH environment variable (recommended)
  4. Select Register Miniconda3 as my default Python 3.x

Verifying the Installation

After installation, reopen the terminal and verify:

# Check the conda version
conda --version

# Check conda info
conda info

# Check the Python version
python --version

Conda Basic Usage

1. Environment Management

Creating a New Environment

Python Version Requirement

Synria Robotics' SDK and example code are all validated based on Python ≥ 3.11. Please do not use versions lower than 3.11. The examples below uniformly use python=3.11.

# Create an environment with a specified Python version (change "myenv" as you like)
conda create --name myenv python=3.11

# Create an environment and install packages
conda create --name myenv python=3.11 numpy pandas

Activating/Deactivating an Environment

# Activate the environment
conda activate myenv

# Deactivate the environment
conda deactivate

# List all environments
conda env list
# Or
conda info --envs

Deleting an Environment

# Delete the environment
conda env remove --name myenv

# Confirm deletion
conda env remove --name myenv --yes

2. Package Management

Installing Packages

# Install a single package
conda install numpy

# Install multiple packages
conda install numpy pandas matplotlib

# Install a specific version
conda install numpy=1.21.0

# Install from a specific channel
conda install -c conda-forge opencv

Viewing and Managing Packages

# List installed packages
conda list

# View information about a specific package
conda list numpy

# Update a package
conda update numpy

# Update all packages
conda update --all

# Uninstall a package
conda remove numpy

If you have any questions, check the official documentation for answers