Skip to main content

How to Use Miniconda for Isolated Python Environments

Python Environments

How to Use Miniconda for Isolated Python Environments

Miniconda gives you a clean way to create isolated Python environments for each project, which helps prevent package conflicts and makes your setups easier to reproduce.

MiniConda Series

Main problem

Different Python projects often need different package and Python versions.

Main fix

Create one Conda environment per project.

Main habit

Keep the base environment lean and avoid doing project work in it.

Why it matters
Why Miniconda matters If you have ever installed a package for one Python project and accidentally caused problems in another, you have already seen why isolated environments matter. Miniconda gives you a small Conda setup that helps keep projects separate.
Workflow

The Basic Workflow

  1. Create an environment for a project
  2. Activate it
  3. Install packages inside that environment
  4. Do your work
  5. Export the environment when you need to share or rebuild it
Foundations

What Miniconda Is

Miniconda is a minimal Conda installation. It gives you Conda, Python, and a small set of core dependencies.

Unlike Anaconda, which installs a much larger package collection up front, Miniconda starts small and lets you install only what you actually need.

Why that is useful A smaller starting point is easier to understand, easier to control, and usually a better fit for project-based Python work.
Core idea

What a Conda Environment Is

A Conda environment is an isolated workspace for a project.

Each environment can have its own:

  • Python version
  • installed packages
  • dependency graph
Project A
Python 3.10
numpy 1.26

Project B
Python 3.8
numpy 1.21

Both environments can exist on the same machine without stepping on each other.

The simplest rule to remember Use one environment per project.
Installation

Installing Miniconda

Installation steps vary a little by operating system and CPU architecture.

macOS (Intel)

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh

macOS (Apple Silicon)

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
bash Miniconda3-latest-MacOSX-arm64.sh

Linux

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

Windows

Download the installer for Windows and run it normally.

Important Windows note Do not add Miniconda to your PATH manually. Use Miniconda Prompt, or use a shell that Conda has initialized for you.

After installation, open a new terminal and verify Conda is working:

conda --version
First workflow

A Typical Miniconda Workflow

conda create --name project1 python=3.10
conda activate project1
conda install numpy pandas
conda export --from-history --file environment.yml

That is the core pattern you will repeat for most projects.

Environment creation

Creating an Environment

It is a good habit to choose the Python version when you create an environment.

conda create --name myenv python=3.10

Example:

conda create --name data-analysis python=3.11
Activation

Activating and Deactivating Environments

Activate an environment:

conda activate myenv

Your shell prompt will usually change to show the active environment:

(base) user@computer % conda activate myenv
(myenv) user@computer %

Deactivate it with:

conda deactivate
Package management

Installing Packages

Install packages inside the active environment.

conda install numpy pandas matplotlib

Conda resolves dependencies for you, which is one reason it is useful for environment management.

If a package is not available through Conda

You can use pip inside the active environment:

pip install somepackage
Rule of thumb Try Conda first. Use pip only when necessary, and avoid mixing Conda and pip casually in the same environment.
Maintenance

Listing and Removing Environments

List environments:

conda env list

Remove an environment:

conda env remove --name myenv
Sharing

Exporting and Recreating Environments

If you want to share an environment or rebuild it later, export it to a file.

Cleaner export for many projects

conda export --from-history --file environment.yml

This keeps the file more focused by recording what you explicitly asked Conda to install rather than every resolved package in the environment.

Another common export form

conda env export > environment.yml

This can be useful when you want a fuller snapshot of the environment.

Recreate the environment

conda env create -f environment.yml
Mistakes to avoid

Common Beginner Mistakes

Installing packages in base

The base environment is best kept lean. For real project dependencies, create a separate environment instead.

Forgetting to activate the environment

If the environment is not active, you may install packages somewhere you did not intend.

Mixing pip and Conda randomly

This is one of the fastest ways to make an environment harder to reproduce and harder to debug later.

Reference

Useful Commands

Task Command
Check Conda version conda --version
Create environment conda create --name myenv python=3.10
Activate environment conda activate myenv
Deactivate environment conda deactivate
Install packages conda install numpy pandas
List environments conda env list
Export environment conda export --from-history --file environment.yml
Recreate environment conda env create -f environment.yml
Remove environment conda env remove --name myenv
Cheat sheet
Quick cheat sheet
conda create --name myenv python=3.10
conda activate myenv
conda install numpy pandas
conda export --from-history --file environment.yml
conda deactivate
FAQ

Frequently Asked Questions

These are the practical questions that usually come up when starting with Miniconda and isolated Python environments.

What is the difference between Conda and Miniconda?

Conda is the package and environment manager. Miniconda is the small installer that gives you Conda, Python, and a minimal starting setup.

Is Miniconda better than Anaconda?

Miniconda is often the better choice when you want a smaller installation and tighter control over what gets installed.

Can Conda manage non-Python packages?

Yes. Conda can also manage some non-Python packages and dependencies, which is part of what makes it useful for reproducible environments.

Should I use pip or Conda?

Start with Conda. Use pip when the package you need is not available through Conda.

Why should I avoid doing project work in base?

Keeping base lean reduces the chance of package conflicts and makes it easier to reason about what belongs to each project.

What is the simplest habit that makes Conda easier to manage?

Create one environment per project, activate it before installing packages, and export it when you need to share or rebuild it later.

Conclusion

The Miniconda workflow is simple once you make it a habit.

Create one environment per project. Choose the Python version on purpose. Install packages inside the active environment. Export the environment when you need to share or rebuild it.

That small amount of structure goes a long way toward preventing dependency conflicts.

Raell Dottin

Comments