Python Environments (option)
By installing Python, you can use pyROOT and TSrim directly from Python. However, Python is not required to use artemis_crib, so you may skip this section if you do not plan to use Python.
Why Manage Python Environments?
Managing Python environments and dependencies is crucial to avoid compatibility issues. Some configurations may work in specific environments but fail in others due to mismatched dependencies. To address this, we recommend using tools that handle dependencies efficiently and isolate environments.
Popular Tools for Python Environment Management
| Tool | Description |
|---|---|
| pyenv | Manages multiple Python versions and switches between them on the same machine. |
| poetry | A dependency manager and build system for Python projects. |
| pipenv | Combines pip and virtualenv for managing dependencies and virtual environments. |
| mise1 | Runtime manager (e.g., Python, Node.js, Java, Go). Ideal for multi-tool projects. |
| uv | A fast Python project manager (10-100x faster than pip), unifying tools like pip, poetry, and pyenv. |
Using uv for a Global Python Environment
This section explains how to use uv to set up a global Python environment, required for tools like pyROOT. uv typically creates project-specific virtual environments, but here we focus on configuring a global virtual environment. For other methods, refer to the respective tool's documentation.
Step 1: Install uv
Install uv using the following command:
Follow the instructions to complete the installation and configure your environment (e.g., adding uv to PATH).
Verify the installation:
Step 2: Install Python using uv
Install a specific Python version:
- Replace
3.12with the desired Python version. - To view available versions:
Step 3: Create a Global Virtual Environment
To create a global virtual environment:
This creates a .venv directory in $HOME.
Step 4: Persist the Environment Activation
Edit your shell configuration file to activate the virtual environment at startup:
Add:
# Activate the global uv virtual environment
if [[ -d "$HOME/.venv" ]]; then
source "$HOME/.venv/bin/activate"
fi
Apply the changes:
Verify the Python executable:
Ensure the output is .venv/bin/python.
Step 5: Add Common Packages
Install commonly used Python packages into the virtual environment:
Additional information
- For more detail, refer to the uv documentation.
-
The author (okawak) uses a combination of
miseanduvto manage Python environments. If your projects involve multiple tools, such as Python and Node.js, mise is highly effective for unified management. However, if you work exclusively with Python,uvis a simpler and more focused option. ↩