Install Miniconda and create an environment
This is the default path. Install Miniconda, then create a Python 3.12 environment with the scientific packages used in astrophysics analysis. Prefer uv if you want a lighter, project-local workflow instead.
1. Install Miniconda
Use the official installer for your operating system: Miniconda install guide.
macOS
If you use Homebrew:
brew install --cask miniconda
Or download the installer from the Miniconda guide and run it, then initialize conda:
conda init
Linux
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
conda init
Windows
Install WSL 2 first, then install Miniconda inside the Linux environment using the Linux commands above. Reopen the terminal after conda init.
2. Optional: install a compiler toolchain
Some scientific packages need C/C++ compilers. Install the tools for your platform before building packages.
3. Create and activate a conda environment
Create a project environment for astrophysics work:
conda create -n astro-python python=3.12
Activate it:
conda activate astro-python
Install the core scientific tools:
conda install -c conda-forge jupyterlab matplotlib numpy scipy pandas astropy
To leave the environment later:
conda deactivate
4. Manage conda environments
The active environment appears in your shell prompt, for example (astro-python). You can also list environments; the current one is marked with *:
conda env list
conda info --envs shows the same list.
Activate and deactivate an environment:
conda activate astro-python
conda deactivate
List packages installed in the current environment:
conda list
Add another package later:
conda install -c conda-forge package-name
Export the current environment so someone else can recreate it:
conda env export > environment.yml
Remove an environment. Deactivate it first if it is active. This deletes the whole environment, not a single package:
conda deactivate
conda env remove -n astro-python
conda remove -n astro-python --all does the same thing.
Official reference: Managing environments.
Alternative: uv
If you prefer a modern, project-local environment without a global conda install, use uv instead of this page.