Install & Compatibility
Where this runs
tested against v3.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.9s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
sentry_cli
✓ This package is not intended for direct Python import as a library with an API.
✗ import sentry_cli
sentry-cli is a command-line tool (a binary), not a Python library with an importable API. Its Python package primarily manages the binary installation. For Python application error reporting, use the `sentry-sdk` library. To run `sentry-cli` from Python, use `subprocess`.
This quickstart demonstrates how to programmatically interact with `sentry-cli` from Python using the `subprocess` module. It includes examples for checking the version, creating, and finalizing a Sentry release. Ensure you have `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, and `SENTRY_PROJECT` environment variables configured or set `sentry-cli login` interactively. Replace placeholder slugs with your actual Sentry organization and project details.
import os
import subprocess
# Ensure SENTRY_AUTH_TOKEN is set for non-interactive use (e.g., CI/CD)
# It can be obtained from your Sentry 'API Keys' settings.
# For interactive use, run 'sentry-cli login' once in your terminal.
os.environ['SENTRY_AUTH_TOKEN'] = os.environ.get('SENTRY_AUTH_TOKEN', '')
os.environ['SENTRY_ORG'] = os.environ.get('SENTRY_ORG', 'your-org-slug') # Replace with your Sentry organization slug
os.environ['SENTRY_PROJECT'] = os.environ.get('SENTRY_PROJECT', 'your-project-slug') # Replace with your Sentry project slug
def run_sentry_cli_command(command_args):
full_command = ['sentry-cli'] + command_args
print(f"\nRunning: {' '.join(full_command)}")
try:
result = subprocess.run(
full_command,
capture_output=True,
text=True,
check=True, # Raises CalledProcessError for non-zero exit codes
env=os.environ # Pass current environment including SENTRY_AUTH_TOKEN
)
print("STDOUT:\n" + result.stdout)
if result.stderr:
print("STDERR:\n" + result.stderr)
return result.stdout
except subprocess.CalledProcessError as e:
print(f"Error executing command: {e.cmd}")
print(f"Return Code: {e.returncode}")
print(f"STDOUT:\n{e.stdout}")
print(f"STDERR:\n{e.stderr}")
raise # Re-raise the error to stop execution
except FileNotFoundError:
print("Error: 'sentry-cli' command not found. Please ensure it's installed and in your system PATH.")
print("You can install it via 'pip install sentry-cli' or by following instructions at https://docs.sentry.io/product/cli/installation/")
raise
if __name__ == "__main__":
try:
# 1. Check the Sentry CLI version
run_sentry_cli_command(['--version'])
# 2. Get the current organization's status
run_sentry_cli_command(['info'])
# 3. Create a Sentry release (replace with your actual release name)
release_name = f"my-app@{os.getenv('BUILD_VERSION', '1.0.0-test')}"
run_sentry_cli_command(['releases', 'new', release_name])
# 4. Set the release to committed (optional, for connecting to SCM)
# run_sentry_cli_command(['releases', 'set-commits', release_name, '--auto'])
# 5. Finalize the release
run_sentry_cli_command(['releases', 'finalize', release_name])
print("\nSentry CLI commands executed successfully!")
except Exception as e:
print(f"\nAn error occurred during quickstart execution: {e}")
sentry-cli --version
Upgrade
Version history
3.5.0latest on PyPI · released Jun 2, 2026
Audit
Dependencies
No dependency data recorded yet.