What a Conda environment is and why you need one
A Conda environment is an isolated folder on your computer that holds a specific version of Python and the packages your project needs. When you create an environment, you're not installing anything into your main system — you're building a sandbox where your project can have exactly the versions it requires without affecting other projects or breaking your system Python.
The reason to use one is simple: different projects need different package versions. Project A might need NumPy 1.19, while Project B needs NumPy 1.24. Without environments, installing one breaks the other. Conda solves this by letting each project live in its own space with its own dependencies.
Conda is a package and environment manager that comes with Anaconda or Miniconda. If you haven't installed either yet, download Miniconda from conda.io — it's smaller than Anaconda and includes everything you need to create environments.
Key Takeaways
- A Conda environment is an isolated folder containing a specific Python version and the packages your project needs, keeping projects from interfering with each other.
- You create an environment with a single command: conda create --name myenv python=3.11, replacing myenv with your project name.
- Before you can use packages in an environment, you must activate it with conda activate myenv on Windows, Mac, or Linux.
- Install packages into the active environment with conda install packagename, and Conda will find compatible versions automatically.
- Save your environment's package list to a file with conda export > environment.yml so others can recreate it exactly.
Creating your first environment from the command line
Open your terminal (Terminal on Mac or Linux, Command Prompt or PowerShell on Windows). Type this command and press Enter:
conda create --name myproject python=3.11
Replace myproject with whatever you want to call your environment — use something that describes the project. Replace 3.11 with the Python version you need. Conda will download Python 3.11 and a few core packages, then ask you to confirm by typing y and pressing Enter.
If you don't specify a Python version, Conda installs the latest one by default. If you need a specific version because your project requires it, check your project's documentation first.
Activating an environment so you can use it
Creating an environment doesn't automatically use it — you have to activate it first. In your terminal, type:
conda activate myproject
You'll see your environment name appear in parentheses at the start of your terminal prompt, like (myproject) $. This tells you the environment is active and any packages you install or Python code you run will use this environment's Python and packages.
To deactivate and return to your system Python, type conda deactivate. You'll see the parentheses disappear from your prompt.
Installing packages into your environment
Make sure your environment is active — you should see its name in parentheses in your prompt. Then type:
conda install numpy pandas matplotlib
This installs NumPy, Pandas, and Matplotlib all at once. You can install one package at a time or several together — Conda will figure out which versions work together and download them. If Conda can't find compatible versions, it will tell you and suggest alternatives.
You can also specify a version: conda install numpy=1.24. If you need a package that Conda doesn't have, you can use pip instead: pip install packagename. Pip and Conda work together in the same environment.
Saving and sharing your environment
When your project is done and working, save a record of what you installed so you or someone else can recreate it exactly. With your environment active, type:
conda export > environment.yml
This creates a file called environment.yml in your current folder that lists every package and version. Share this file with your project code. Someone else can recreate your environment by typing:
conda create --file environment.yml
This is especially useful if you're sharing code on GitHub or with a team — they won't have to guess which versions you used.
Listing and removing environments
To see all your environments, type:
conda env list
You'll see a list with an asterisk next to the active one. If you finish a project and want to delete its environment, type:
conda remove --name myproject --all
This deletes the entire environment folder and frees up disk space. You can always recreate it later if you need it again.
Frequently Asked Questions
What's the difference between Anaconda and Miniconda?
Anaconda includes Conda plus about 250 pre-installed packages and a graphical interface. Miniconda is just Conda and Python — you install packages as you need them. For most people, Miniconda is faster to download and uses less disk space. Both create environments the same way.
Can I use pip and Conda together in the same environment?
Yes. Conda is better at resolving version conflicts, so install what you can with Conda first, then use pip for packages Conda doesn't have. Install pip packages after Conda packages to avoid conflicts.
How do I know which Python version my project needs?
Check your project's README, requirements file, or documentation. If it doesn't say, start with Python 3.11 or 3.12 — they're stable and widely supported. You can always create a new environment with a different version if the first one doesn't work.
What happens if I forget to activate my environment?
You'll use your system Python instead, and packages won't be found or will use the wrong versions. If your code fails with "module not found" errors, check that your environment is active — you should see its name in parentheses in your prompt.
Can I rename an environment after I create it?
Conda doesn't have a rename command. Instead, export it to a file with conda export > environment.yml, create a new environment with the new name using that file, then delete the old one with conda remove --name oldname --all.