← All posts

A Beginner’s Guide to Python Environments (Miniconda vs. Anaconda)

Data-Sci & Digital HealthClinical Epidemiology ResearchData Analytics or StatisticsPython [Data Analytics]
On this page

Introduction

A Beginner’s Guide to Python Environments

A clean, practical introduction for new programmers, researchers, and CECS students

Managing Python environments is one of the most important early skills for anyone entering programming, data science, or clinical statistics. Many beginners underestimate this topic—until they face problems such as:

A proper environment setup saves hours of debugging and keeps projects reproducible and clean.


What Exactly Is a Python Environment?

Think of a Python environment like a special room designed for a specific task:

A Python environment works the same way:

This avoids conflicts between projects. For example:

ProjectPython Versionpandas Versionnumpy Version
COVID risk model3.122.11.26
Hospital LOS prediction3.91.51.20

Each project remains isolated.


Miniconda vs. Anaconda

Both use the Conda package/environment manager, but they differ in how much they install up front.

Anaconda Distribution

Best for serious learners and researchers: Miniconda.


Why Environments Matter

If you install everything inside the global base environment:

Separate environments ensure:

✔ Clean versions ✔ Conflict-free installations

✔ True reproducibility ✔ Stable clinical-statistical pipelines (critical in CECS research)

This parallels CECS principles: keep analysis datasets isolated, avoid contamination, and maintain reproducibility .


How Conda Environments Work

Here’s what your commands actually did, explained.

✔ Listing installed packages

conda list

Shows what is installed in the current environment.

✔ Creating a new environment

conda create -n test_env python=3.13

This creates a fresh environment named test2_env with its own Python 3.13 interpreter.

✔ Activating the environment

conda activate test_env

Your terminal prefix changes to (test_env) → meaning you are now inside that environment.

✔ Installing packages inside the environment

pip install pandas

Since you're inside test_env, pandas is installed only there — not system-wide.

This isolation principle is similar to CECS analysis logic where each model class (logistic, Cox, Poisson) is fitted according to the specific data structure and assumptions, avoiding contamination from unrelated settings .


How to Use Conda Environments in IDEs

Most beginners forget this step!

✔ Visual Studio Code (VS Code)

  1. Press Ctrl + Shift + P
  2. Search Python: Select Interpreter
  3. Choose your conda environment path:.../.conda/envs/test_env/python.exe

✔ PyCharm

  1. File → Settings → Project → Interpreter
  2. Add Interpreter → Conda
  3. Select Existing environment: test_env

✔ Jupyter Notebook / JupyterLab

Install a Jupyter kernel associated with the environment:

pip install ipykernel
python -m ipykernel install --user --name test2_env --display-name "Python (test2_env)"

You will then be able to choose the kernel inside Jupyter.


Essential Conda Commands (Beginner Cheat Sheet)

Create environment

conda create -n my_env python=3.12

Activate / deactivate

conda activate my_env
conda deactivate

List environments

conda env list

Install packages

conda install numpy
pip install numpy

Remove a package

conda remove numpy

Delete an environment

conda remove -n my_env --all


How Python Environments Support CECS Workflows

Although environments are a programming concept, they directly support the CECS statistical workflow:

✔ Reproducibility

Survival analysis, prediction modeling, and causal inference must run identically across machines and dates. Environment isolation prevents version drift—critical for clinical reproducibility and model validation.

✔ Compatibility

Different analyses require different versions of packages:

Separate environments let each project choose the right set of tools.

✔ Clean Model Development

Just like CECS modeling strategies avoid mixing explanatory, exploratory, and predictive frameworks , software environments should also remain cleanly separated.

0
Message for International and Thai ReadersUnderstanding My Medical Context in ThailandRead more →Message for International and Thai ReadersUnderstanding My Broader Content Beyond MedicineRead more →

Comments

No comments yet. Be the first to share your thoughts.

Sign in to comment