{"id":21738,"library":"pychromecast","title":"PyChromecast","description":"Python module to talk to Google Chromecast. v14.0.10 requires Python >=3.11. Active development by Home Assistant team.","status":"active","version":"14.0.10","language":"python","source_language":"en","source_url":"https://github.com/home-assistant-libs/pychromecast","tags":["chromecast","google-cast","media","home-assistant","mDNS"],"install":[{"cmd":"pip install pychromecast","lang":"bash","label":"Latest stable"}],"dependencies":[{"reason":"Required for Chromecast protocol messages","package":"protobuf","optional":false},{"reason":"Required for discovery","package":"zeroconf","optional":false}],"imports":[{"note":"Not a top-level attribute in the package module.","wrong":"import pychromecast; Chromecast()","symbol":"Chromecast","correct":"from pychromecast import Chromecast"},{"note":"get_chromecasts moved to top-level in v14.","wrong":"from pychromecast.discover import get_chromecasts","symbol":"get_chromecasts","correct":"from pychromecast import get_chromecasts"},{"note":"","wrong":"","symbol":"ChromecastInfo","correct":"from pychromecast import ChromecastInfo"}],"quickstart":{"code":"import os\nimport time\nimport pychromecast\n\ncasts, browser = pychromecast.get_chromecasts()\nif casts:\n    cast = casts[0]\n    cast.wait()\n    print(cast.device.friendly_name)\n    mc = cast.media_controller\n    mc.play_media('http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', 'video/mp4')\n    time.sleep(5)\n    browser.stop_discovery()","lang":"python","description":"Discovers Chromecasts on the network, connects to the first found, and plays a test video."},"warnings":[{"fix":"Update calls to use keyword arguments, e.g., cast.register_handler(handler, is_registered=True).","message":"Breaking change in v14: optional callback arguments are now keyword-only. Passing positional callbacks will raise TypeError.","severity":"breaking","affected_versions":">=14.0.0"},{"fix":"Use keyword arguments: ServiceInfo(uuid=..., services=..., etc.).","message":"ServiceInfo class replaced with dataclass in v14. Instantiating with positional arguments breaks.","severity":"breaking","affected_versions":">=14.0.0"},{"fix":"Always call browser.stop_discovery() when done, or use context manager: with pychromecast.get_chromecasts() as (casts, browser):","message":"get_chromecasts() returns a list and a Browser object. The Browser must be stopped to avoid resource leaks.","severity":"gotcha","affected_versions":"all"},{"fix":"Call cast.wait() before using cast.device or other attributes.","message":"Cast device may not be ready immediately after get_chromecasts(). Accessing properties before wait() can cause AttributeError.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use from pychromecast import Chromecast or from pychromecast.controllers import Chromecast","cause":"Importing directly from pychromecast module without knowing the correct import path.","error":"AttributeError: module 'pychromecast' has no attribute 'Chromecast'"},{"fix":"Use keyword arguments: get_chromecasts(blocking=True, callback=my_callback)","cause":"Passing positional arguments that are now keyword-only in v14.","error":"TypeError: get_chromecasts() got multiple values for argument 'blocking'"},{"fix":"Ensure only one zeroconf instance is active per process. Upgrade zeroconf to >=0.118.0.","cause":"Running multiple instances of ZeroConf service or incorrect zeroconf version.","error":"zeroconf.BadServiceType: Service type '_googlecast._tcp.local.' is not valid"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}