Conda Create Environment

Conda Create Environment

Conda Create Environment


Conda Create Environment: Complete Step-by-Step Guide (2026)

Introduction

A few years ago I broke a client's machine-learning project by upgrading one package. Everything on my laptop shared a single Python installation, so one pip install quietly broke three other projects. That was the day I stopped installing things globally and started using isolated environments.

Conda Create Environment


If you work with Python, data science or machine learning, learning how to conda create environment is one of the most useful habits you can build. In this guide I'll walk through how to conda create new environment, conda list environments, run conda install inside the right environment, and safely use conda delete environment or conda remove environment when a project is finished. Every command below is one I use regularly.

What Is a Conda Environment?

A conda environment is an isolated folder that holds its own Python version and its own set of packages. Projects stay separate, so Project A can use Python 3.9 with an old library while Project B uses Python 3.12 with the latest one, and neither affects the other.

Why developers use it

Conda manages more than Python packages. It also installs compiled libraries (like CUDA tools, MKL and OpenSSL), which is why data science teams prefer it over a plain virtual environment.

One machine, many isolated conda environments Conda installation (miniconda3 / anaconda3) base default env keep it clean web-api Python 3.11 flask, requests ml-lab Python 3.10 numpy, pytorch legacy-app Python 3.8 old pinned libs

Prerequisites

You need Miniconda or Anaconda installed. Check it with:

conda --version

If you see a version number, you are ready. I recommend Miniconda because it is small and installs only what you ask for.

Conda Create Environment: The Basic Command

Create a new environment with a Python version

conda create --name myenv python=3.11

Conda shows a package plan and asks for confirmation. Type y and press Enter. The short form -n works the same as --name.

Create an environment and install packages at once

conda create -n datasci python=3.11 numpy pandas matplotlib

Installing everything in one command lets conda solve all dependencies together, which avoids many conflicts later. It is a habit I'd suggest from day one.

Create an environment in a specific folder

conda create --prefix ./envs/myproject python=3.11

This keeps the environment inside your project directory. Activate it with conda activate ./envs/myproject.

Activate and deactivate

conda activate myenv
conda deactivate

After activation your terminal prompt shows (myenv) at the start. Anything you install now goes only into this environment.

Conda List Environments

To see every environment on your machine, use either of these:

conda env list
conda info --envs

The active environment is marked with an asterisk (*). To see the packages inside the current environment, run conda list. For another environment, use conda list -n myenv.

Conda Install Packages in an Environment

Use conda install after activating the environment:

conda activate myenv
conda install scikit-learn

You can also install without activating by naming the environment:

conda install -n myenv scipy

Install from a different channel

conda install -c conda-forge fastapi

The conda-forge channel is community-maintained and often has newer packages than the default channel.

A note on mixing pip and conda

When a package is not on conda, pip install inside the active environment works. My rule: install everything you can with conda first, then use pip last. Mixing them in the other order is where most strange breakages come from.

Conda environment lifecycle 1. Create conda create -n 2. Activate conda activate 3. Install conda install 4. List conda env list 5. Remove conda env remove Export with environment.yml to share the setup with your team

Conda Remove Environment and Conda Delete Environment

Conda has no command literally named "delete", so "conda delete environment" and "conda remove environment" mean the same thing. Deactivate first, then run either of these:

conda deactivate
conda env remove --name myenv

The alternative is:

conda remove --name myenv --all

For an environment created with --prefix, use conda env remove --prefix ./envs/myproject. Then run conda env list to confirm it is gone.

Careful: removing an environment is permanent. Export it first if you may need it again.

Save, Share and Clone Environments

Export to environment.yml

conda env export --name myenv > environment.yml

Recreate from the file

conda env create -f environment.yml

Clone an existing environment

conda create --name myenv-copy --clone myenv

Cloning is a safe way to test a risky upgrade without touching the working setup.

Quick Command Cheat Sheet

TaskCommand
Create new environmentconda create -n myenv python=3.11
Activateconda activate myenv
List environmentsconda env list
Install packageconda install -n myenv numpy
Delete / remove environmentconda env remove -n myenv
Export environmentconda env export > environment.yml

Common Problems and Fixes

"conda: command not found"

Conda is not on your PATH. Run conda init (or open the Anaconda Prompt on Windows) and restart your terminal.

"EnvironmentNameNotFound"

Check the spelling with conda env list. Names are case-sensitive on Linux and macOS.

Solving environment takes forever

Update conda with conda update conda. Recent versions use the fast libmamba solver, and installing packages in one command also helps.

Cannot remove the active environment

Run conda deactivate first, then remove it.

Best Practices I Follow

  • One environment per project. Never install project packages in base.
  • Name environments clearly. blog-scraper beats test2.
  • Pin the Python version when you create it.
  • Export environment.yml and commit it with your code.
  • Clean up old environments with conda env remove and conda clean --all.

Frequently Asked Questions (FAQ)

1. How do I conda create environment with a specific Python version?

Run conda create --name myenv python=3.11. Replace 3.11 with the version you need, then activate it with conda activate myenv.

2. How do I conda list environments?

Use conda env list or conda info --envs. Both print every environment and its path, with an asterisk next to the active one.

3. What is the command to conda delete environment?

There is no "delete" command. Use conda env remove --name myenv or conda remove --name myenv --all after deactivating it.

4. Can I conda install a package without activating the environment?

Yes. Add the environment name: conda install -n myenv pandas. Conda installs it into that environment without switching.

5. What is the difference between conda environments and venv?

venv isolates Python packages only and uses the Python already on your system. Conda can install different Python versions and non-Python libraries too, which suits data science and machine learning work.

Conclusion

Once you get used to it, working with environments takes only a few commands: conda create environment to start, conda install to add what you need, conda list environments to keep track, and conda remove environment to clean up. Keep each project isolated and export an environment.yml, and "it works on my machine" problems mostly disappear.

If this guide helped, share it with a teammate who still installs everything globally, and tell me in the comments which conda command saved you the most time.

Read More.






AngularThink
Written by AngularThink Team
Full-Stack & AI engineering insights, tutorials and best practices.

0 Comments

Post a Comment