Set Default Python Kernel for Quarto
To set the default Python kernel for Quarto, you have a few options depending on whether you want to set it globally, per-project, or per-document.
Option 1: Set QUARTO_PYTHON globally (Recommended for a system-wide default)
The most reliable way to force Quarto to use a specific Python executable globally is by setting the QUARTO_PYTHON environment variable in your shell profile (e.g., ~/.zshrc or ~/.bashrc).
-
Find the path to the Python environment you want to use (e.g., your
earth-analytics-pythonconda environment):conda activate earth-analytics-python which python -
Add that path to your
~/.zshrcfile:export QUARTO_PYTHON="/path/to/your/earth-analytics-python/bin/python" -
Restart your terminal or run
source ~/.zshrc.
Option 2: Specify the Kernel in the Document’s YAML Header
If you want to ensure a specific Quarto document (.qmd) always uses the earth-analytics-python kernel, you can specify it directly in the YAML front matter of the document.
You’ll need the exact Jupyter kernelspec name. You can list your available Jupyter kernels by running:
jupyter kernelspec list
Once you have the kernel name, add it to your .qmd file like this:
---
title: "My Document"
jupyter:
kernelspec:
display_name: earth-analytics-python
language: python
name: earth-analytics-python # Replace with the actual kernel name if different
---
Option 3: Activate the Environment Before Rendering
By default, Quarto will automatically detect and use the Python interpreter that is currently active in your terminal. You can simply activate the environment before running your Quarto commands:
conda activate earth-analytics-python
quarto render your_document.qmd