June 23, 2026 | 5 min read
Setting Up a Scientific Python Environment on macOS (Apple Silicon)
This guide walks through creating a dedicated scientific Python environment called numerics, installing common scientific packages, and making the environment available inside Jupyter notebooks.
The instructions assume:
- macOS on Apple Silicon (M1/M2/M3)
- Python installed via Homebrew
- Terminal application available
1. Check Your Python Installation
Before creating an environment, verify that Python is installed and available from Homebrew.
python3 --versionwhich python3
Expected output:
Python 3.14.x/opt/homebrew/bin/python3
If Python is not installed through Homebrew, install it first:
brew install python
2. Create a Dedicated Virtual Environment
Using a virtual environment keeps scientific packages isolated from the system Python installation.
Create a directory to store virtual environments:
mkdir -p ~/venvs
Create the environment:
python3 -m venv ~/venvs/numerics
Activate it:
source ~/venvs/numerics/bin/activate
Your shell prompt should now begin with:
(numerics)
Confirm that Python is coming from the virtual environment:
which python
Expected output:
/Users/subhodeep/venvs/numerics/bin/python
3. Upgrade Packaging Tools
Upgrade the package-management tools before installing scientific software:
pip install --upgrade pip setuptools wheel
Verify:
pip --version
4. Create a Requirements File
Create a file named:
~/numerics-requirements.txt
Populate it with the packages you want installed.
Example:
numpyscipypandasmatplotlibseabornnumbaipykerneljupyterlab
5. Install the Scientific Stack
Install all packages listed in the requirements file:
pip install -r ~/numerics-requirements.txt
Depending on the number of packages and internet speed, installation may take several minutes.
Occasionally you may see messages such as:
WARNING: Cache entry deserialization failed, entry ignored
These warnings are generally harmless and can be ignored.
6. Register the Environment with Jupyter
Register the virtual environment as a Jupyter kernel so it appears as a selectable notebook kernel.
python -m ipykernel install \--user \--name numerics \--display-name "Python (numerics)"
After completion, Jupyter notebooks will offer:
Python (numerics)
as a kernel option.
7. Test the Installation
Launch an interactive Python session:
python
Run:
import numpyimport scipyimport pandasimport matplotlibimport seabornimport numbaprint("OK")
Expected output:
OK
Exit Python:
quit()
8. Verify Jupyter Kernel Registration
List all installed Jupyter kernels:
jupyter kernelspec list
Example output:
Available kernels:numericsjulia-1.12wolframlanguage13.3
The exact list will depend on your machine.
9. Daily Usage
Activate the environment whenever you want to work in it:
source ~/venvs/numerics/bin/activate
Deactivate when finished:
deactivate
Install additional packages later:
pip install PACKAGE_NAME
Upgrade a specific package:
pip install --upgrade PACKAGE_NAME
Check for outdated packages:
pip list --outdated
10. Create a Reproducible Snapshot
Save the exact package versions currently installed:
pip freeze > ~/numerics-lock.txt
The generated file can later be used to recreate the environment exactly:
pip install -r ~/numerics-lock.txt
This is useful for reproducible research, sharing environments with collaborators, and recovering a working setup after system upgrades.
11. Create a Quick-Access Alias
To jump into your scientific environment from any terminal directory, add an alias to your shell configuration file.
Open your .zshrc file:
nano ~/.zshrc
Add this line to the bottom:
# Scientific Python Environmentalias numerics='source ~/venvs/numerics/bin/activate'
Save, exit, and reload:
source ~/.zshrc
Now, simply type numerics in any terminal to jump into your workspace.
Useful Commands
Show Installed Packages
pip list
Display Environment Location
which python
Display Package Details
pip show numpy
Remove the Environment Completely
rm -rf ~/venvs/numerics
Remove the Jupyter Kernel
jupyter kernelspec uninstall numerics
Requirements File (numerics-requirements.txt)
Create this file in your home directory (~/) , this file defines the full scientific stack that will be installed:
# Core & High-Performancenumpyscipynumbanumexprjoblibpsutil# Data Analysis & Storagepandasxarraydaskh5pytableszarr# Visualizationmatplotlibseabornplotly# Math & Symbolicsympyuncertaintiesmpmath# Statistics & Inferencestatsmodelsscikit-learnemceecornerlmfit# Domain Specificastropy# Interoperabilityjuliacallwolframclient# Terminal & Formattingtabulateprettytablerichtqdm# Jupyterjupyterlabipykernel