PBS Installer
pbs-installer is a Python library that serves as an installer for @indygreg's python-build-standalone. It automates the process of downloading and installing specific Python versions in a standalone fashion. The library is actively maintained with frequent releases, often multiple times a month, and is currently at version 2026.3.25.
Warnings
- gotcha Full functionality requires optional dependencies `httpx` and `zstandard`. Without them, downloading might fail (e.g., `ModuleNotFoundError` for `httpx`) or Zstandard-compressed builds cannot be extracted.
- gotcha There are multiple unrelated Python libraries or projects with 'PBS' in their name (e.g., `pbs-python` for Torque/OpenPBS, `pbs` for subprocess management). Ensure you are importing and using `pbs_installer` from `frostming` for Python Build Standalone installations.
- gotcha The `request` parameter for the `install` function expects specific Python version strings (e.g., '3.10', '3.10.4', 'pypy-3.9'). Passing malformed or ambiguous strings might result in a `ValueError` if a matching build cannot be found.
- gotcha When installing Python for a different target environment (cross-compiling) or if auto-detection fails, explicitly specifying the `arch` and `platform` parameters in the `install` function is crucial. Omitting them might lead to downloading an incompatible Python build for the current system.
Install
-
pip install pbs-installer -
pip install pbs-installer[all] -
pipx install pbs-installer
Imports
- install
from pbs_installer import install
- download
from pbs_installer import download
Quickstart
import os
from pbs_installer import install
# Define the target directory for Python installation
install_path = os.path.join(os.getcwd(), "my_python_env")
python_version = "3.10" # Example: install CPython 3.10
print(f"Attempting to install CPython {python_version} to {install_path}")
try:
# Ensure optional dependencies are installed for full functionality, e.g., via `pip install pbs-installer[all]`
install(request=python_version, destination=install_path)
print(f"CPython {python_version} installed successfully to {install_path}")
except Exception as e:
print(f"Error installing Python: {e}")
# Example of how to verify installation (simplified)
# This would typically involve checking for the python executable in install_path
python_executable = os.path.join(install_path, 'bin', 'python') if os.name == 'posix' else os.path.join(install_path, 'python.exe')
if os.path.exists(python_executable):
print(f"Python executable found at: {python_executable}")
else:
print(f"Python executable NOT found at: {python_executable}")