Conda
package management
Python
environment management
software installation

How can I run Conda?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Running Conda correctly is mostly about shell setup and environment activation. Many issues come from trying to run conda before initialization, or mixing base and project dependencies in one environment. This guide shows a clean setup and daily workflow for reliable use.

Verify Installation and Initialize the Shell

Start by checking that Conda is installed and reachable.

bash
conda --version

If the command is not found, initialize your shell profile.

bash
conda init zsh
# or
conda init bash

Then restart the terminal or source your profile file so the activation functions are loaded.

bash
source ~/.zshrc

Now conda info should work.

bash
conda info

Create and Activate Environments

Use one environment per project to avoid dependency conflicts.

bash
conda create -n analytics python=3.12 -y
conda activate analytics
python --version

Install packages after activation.

bash
conda install numpy pandas -y
python -c "import numpy, pandas; print('ok')"

Deactivate when done.

bash
conda deactivate

This keeps your base environment clean and prevents cross-project contamination.

Run Commands Without Activating

conda run is useful in scripts, CI jobs, or one-off commands where interactive activation is not ideal.

bash
conda run -n analytics python -c "import sys; print(sys.version)"
conda run -n analytics pytest

This is especially helpful when non-interactive shells do not load profile scripts.

Use Conda and Pip Safely Together

Some packages exist only on pip. Install Conda packages first, then pip packages, and avoid switching back and forth repeatedly.

bash
conda activate analytics
conda install scipy -y
python -m pip install fastapi uvicorn

After mixed installs, test imports quickly.

bash
python -c "import scipy, fastapi; print('imports ok')"

Consistent ordering reduces dependency resolver surprises.

Troubleshooting Common Startup Issues

If activation fails in terminal sessions, inspect environment variables and shell hook state.

bash
echo $SHELL
which conda
conda config --show | rg auto_activate_base

You can disable automatic base activation if you prefer explicit control.

bash
conda config --set auto_activate_base false

On Windows, use Anaconda Prompt or PowerShell after conda init powershell to ensure activation scripts load correctly.

Use Environment Files for Repeatable Setup

Manual installs are fine for exploration, but committed environment files make onboarding and CI much more reliable. Export after you confirm the environment works.

bash
conda activate analytics
conda env export --from-history > environment.yml

Teammates can reproduce with one command.

bash
conda env create -n analytics -f environment.yml

You can also use channels explicitly in the file for deterministic package sources.

yaml
1name: analytics
2channels:
3  - conda-forge
4dependencies:
5  - python=3.12
6  - numpy
7  - pandas

This approach turns local setup from tribal knowledge into versioned project configuration.

For long-lived projects, schedule periodic environment refresh checks so outdated dependencies do not accumulate silently. A small monthly check usually prevents larger upgrade incidents later.

A short bootstrap script that checks Conda availability and creates the environment when missing can save hours during onboarding for new contributors.

Common Pitfalls

A frequent pitfall is installing everything into base, then fighting version conflicts across unrelated projects. Another issue is running pip before environment activation, which installs into the wrong interpreter path. Teams also sometimes run commands in CI without shell initialization and assume Conda is broken. In those cases, conda run is typically the most robust path. Finally, avoid copying full environment directories between machines. Recreate environments from a specification file for consistent results.

Summary

  • Initialize your shell so conda and activation commands are available.
  • Create one environment per project and activate before installing.
  • Use conda run for non-interactive scripts and CI workflows.
  • Install Conda packages first, then pip-only dependencies if needed.
  • Keep environments reproducible with exported configuration files.
  • Document setup commands in the repository so onboarding stays predictable.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.