Environment#
A Python environment is an isolated workspace that contains a specific Python version along with libraries, dependencies, and tools. Managing environments is essential for:
Reproducibility of projects
Preventing version conflicts
Allowing multiple projects with different dependencies
Providing a clean and controlled space for development
There are several environment managers and distributions available.
The most popular ones are:
Conda
Miniconda
Mamba
Anaconda
pip + venv
Other Python distributions such as WinPython or ActivePython
1. Conda (Anaconda / Miniconda)#
Conda is one of the most widely used environment and package managers, especially in data science.
๐น Key Features#
Feature |
Conda |
|---|---|
Manages Python environments |
โ |
Installs non-Python packages (C/C++, CUDA, Rโฆ) |
โ |
Works offline once packages are downloaded |
โ |
Huge scientific stack (NumPy, Pandas, Jupyterโฆ) |
โ |
๐น Example Commands#
conda create --name myenv python=3.11
conda activate myenv
conda install numpy pandas
conda list
conda remove --name myenv --all # delete environment
Conda is recommended for beginners and heavy scientific workloads.
2. Anaconda vs Miniconda#
Feature |
Anaconda |
Miniconda |
|---|---|---|
Preloaded packages |
โ Many (>150) |
โ Minimal installation only |
Size |
Large (~3GB installed) |
Small (~400MB) |
Best for |
Beginners, ready-to-use environment |
Custom lightweight environments |
If you want fast install and flexibility โ choose Miniconda
If you want everything pre-installed โ choose Anaconda
3. Mamba (fast Conda alternative)#
Mamba is a drop-in replacement for conda, built in C++ and optimized for speed.
It solves dependencies much faster and is ideal for large environments or automated workflows.
Example#
mamba create -n myenv python=3.10
mamba install scipy jupyter
Good for:
Large environment creation
Continuous integration (CI) pipelines
Faster dependency solver than conda
4. pip + venv (lightweight Python standard tool)#
For pure-Python packages or smaller development environments, pip + venv is often sufficient. It comes built into Python, making it an excellent lightweight alternative when full package management like Conda is unnecessary.
Create and Activate an Environment#
python -m venv myenv
source myenv/bin/activate # Linux/Mac
myenv\Scripts\activate # Windows
pip install numpy
pip freeze > requirements.txt
Advantages#
Built-in, no extra installation needed
Simple and lightweight
Works well for web development and small projects
Disadvantages#
Limited when installing packages that need compiled dependencies
Less suited for heavy scientific libraries (TensorFlow, GDAL, CUDA-based tools)
5. Environment Comparison Overview#
Choosing the right environment tool depends on workflow, package complexity,
and whether scientific / compiled libraries are required.
Below is a comparison of the most commonly used Python environment managers.
Environment Tool |
Primary Use Case |
Strengths |
Drawbacks |
|---|---|---|---|
Conda |
Data science, ML, scientific computing |
Manages compiled packages, strong isolation, cross-platform |
Dependency solving can be slow |
Mamba |
High-performance Conda replacement |
Very fast installs and environment solving, conda-compatible |
Smaller community and ecosystem size |
Anaconda Distribution |
All-in-one preconfigured environment |
Comes with Jupyter, ML libraries, plotting packages preinstalled |
Large installation size (~3GB) |
Miniconda |
Minimal conda setup for customization |
Lightweight, flexible base for building custom environments |
Requires users to install everything manually |
pip + venv |
General Python development |
Built-in, lightweight, easy to use |
Not ideal for heavy compiled scientific libraries (e.g., TensorFlow, CUDA) |