Skip to main content

Elevate: Request Root Privileges

PyElevate is a small Python library that re-launches the current process with
root/admin. This is essentially a fork of BarneyGale's Elevate with some of the pull requests applied.

Usage

To use, call PyElevate.elevate() early in your script. When run as root, this
function does nothing. When not run as root, this function replaces the current
process (Linux, macOS) or creates a new process, waits, and exits (Windows).

There is also an elevated() function to check if the program is elevated.
This will output a boolean value, with True meaning the program is elevated and False meaning it's not.

from PyElevate import elevate, elevated

if not elevated():
    input("Before: " + str(elevated()) + "\nPress enter to elevate")

elevate()

input("After:" + str(elevated()) + "\nPress enter to elevate")
exit(0)

On Windows, the new process's standard streams are not attached to the parent,
which is an inherent limitation of UAC. By default, the new process runs in a
new console window. To suppress this window, use
elevate(show_console=False).

On Linux and macOS, graphical prompts are tried before sudo by default. To
prevent graphical prompts, use elevate(graphical=False).

Release files for PyElevate 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyElevate 0.1.2
File Size Uploaded
pyelevate-0.1.2.tar.gz 4.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyElevate 0.1.2
File Interpreter ABI Platform
pyelevate-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / pyelevate-0.1.2.tar.gz

Download URL pyelevate-0.1.2.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
60b3b581e3735f83344e9d2d453592e05c36655d1dfad0024097ed38dbdcf7d6
BLAKE2b-256 checksum
How to use checksums
a883ce507743f25c5f5aed23c59d9eab4a8e3f0729e8ac436990cab13a9eb03c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2025.

Transparency log

Release files / pyelevate-0.1.2-py3-none-any.whl

Download URL pyelevate-0.1.2-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abac5a164bc496d802a55975f003813e369ffe3d3a03a3f2bbedc69b080c75fb
BLAKE2b-256 checksum
How to use checksums
1a19e60620564d1e18e7b78303f1e7dee84fd23c55c4dbd15c08a5957cc6aa3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page