{"id":24308,"library":"pycaw","title":"pycaw","description":"Python Core Audio Windows Library - control and manage Windows audio devices, sessions, and endpoints. Current version 20251023, released annually.","status":"active","version":"20251023","language":"python","source_language":"en","source_url":"https://github.com/AndreMiras/pycaw","tags":["audio","windows","com","volume-control","core-audio"],"install":[{"cmd":"pip install pycaw","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for COM interop on Windows","package":"comtypes","optional":false}],"imports":[{"wrong":"from pycaw.pycaw import AudioUtilities","symbol":"AudioUtilities","correct":"from pycaw import AudioUtilities"}],"quickstart":{"code":"from pycaw.pycaw import AudioUtilities\n\ndef set_volume(volume_level):\n    devices = AudioUtilities.GetSpeakers()\n    interface = devices.Activate(\n        AudioUtilities.IID_IAudioEndpointVolume, 1, None)\n    from pycaw.api.endpointvolume import IAudioEndpointVolume\n    volume = interface.QueryInterface(IAudioEndpointVolume)\n    volume.SetMasterVolumeLevelScalar(volume_level, None)\n\nif __name__ == \"__main__\":\n    set_volume(0.5)\n    print(\"Volume set to 50%\")\n","lang":"python","description":"Set master volume to 50% using pycaw."},"warnings":[{"fix":"Use `QueryInterface(InterfaceClass)` instead of `cast(py_object, interface)`.","message":"Double free crash due to using `cast` instead of `QueryInterface` for COM interfaces. Fixed in v20240210 but code using `cast(py_object, ...)` on older versions may crash.","severity":"breaking","affected_versions":"< v20240210"},{"fix":"Change imports to `from pycaw.pycaw import AudioUtilities`.","message":"In v20210516, the `pycaw.pycaw` module was reorganized into subpackages. Code that imported `AudioUtilities` from `pycaw` directly broke.","severity":"breaking","affected_versions":">= v20210516"},{"fix":"Wrap imports with `if sys.platform == 'win32':` or use a try/except for `ModuleNotFoundError`.","message":"pycaw only works on Windows. Importing on Linux/Mac will raise `ModuleNotFoundError` for comtypes or runtime errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Update to v20230407 or later, and ensure PROPVARIANT objects are freed.","message":"Memory leaks from `PROPVARIANT` objects in older versions. Fixed in v20230407, but code that creates many `PROPVARIANT` instances without cleanup may still leak.","severity":"gotcha","affected_versions":"< v20230407"}],"env_vars":null,"search_vec":"'20251023':18 'annual':20 'audio':4,11,21,29 'com':23 'control':7,26 'core':3,28 'core-audio':27 'current':16 'devic':12 'endpoint':15 'librari':6 'manag':9 'pycaw':1 'python':2 'releas':19 'session':13 'version':17 'volum':25 'volume-control':24 'window':5,10,22","created_at":"2026-05-01T08:12:23.436127+00:00","updated_at":"2026-05-01T08:12:23.436127+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'AudioUtilities' from 'pycaw' (/tmp/tmprv1ojgc0/venv/lib/python3.12/site-packages/pycaw/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"20251023","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/AndreMiras/pycaw","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pycaw/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["communication"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}