{"id":22972,"library":"wakepy","title":"wakepy - wakelock / keep-awake / stay-awake","description":"wakepy is a cross-platform library for keeping the system awake (preventing sleep / screen lock) and releasing the wakelock. Version 1.0.0 (requires Python >=3.7). Development is active on GitHub. It supports Windows, macOS, and Linux via DBus.","status":"active","version":"1.0.0","language":"python","source_language":"en","source_url":"https://github.com/wakepy/wakepy","tags":["wakelock","keep-awake","sleep-prevention"],"install":[{"cmd":"pip install wakepy","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"keepawake is a context manager; importing the module directly is insufficient.","wrong":"import wakepy","symbol":"keepawake","correct":"from wakepy import keepawake"}],"quickstart":{"code":"from wakepy import keepawake\n\nwith keepawake():\n    # Your long-running task here\n    import time\n    time.sleep(10)\n    print(\"System stayed awake during this block.\")","lang":"python","description":"Basic usage as a context manager to prevent sleep."},"warnings":[{"fix":"Ensure dbus service is running; use 'pip install wakepy[dbus]' for additional dependencies if needed (though not needed in 1.0.0).","message":"On Linux, wakepy requires D-Bus (typically via systemd or the freedesktop.org inhibitor interface). If DBus is not available, the context manager will raise an error or silently fail in older versions.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Run Python with appropriate privileges or configure polkit rules for your user.","message":"keepawake() may require superuser/administrator privileges on some Linux distributions to inhibit sleep. Without proper permissions, the inhibit may be ignored.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace 'prevent_sleep' with 'keepawake'.","message":"In version 1.0.0, the API was simplified. The old import 'from wakepy import prevent_sleep' is removed. Use 'from wakepy import keepawake'.","severity":"breaking","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install wakepy","cause":"wakepy not installed.","error":"ModuleNotFoundError: No module named 'wakepy'"},{"fix":"Use 'from wakepy import keepawake' and 'with keepawake():' instead.","cause":"API changed in version 1.0.0; prevent_sleep removed.","error":"ImportError: cannot import name 'prevent_sleep' from 'wakepy'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}