Registry / http-networking / pyatv
library0.17.0pypypi✓ verified 86d ago

A Python client library for controlling Apple TV and AirPlay devices. It supports scanning, pairing, and remote control via MRP, Companion, and AirPlay protocols. Current version 0.17.0 requires Python 3.9+, and releases occur roughly every 3-6 months.

pip install pyatv
INSTALL
IMPORT
SIG · PYATV
P
pyatv
http-networkingpythonv0.17.0
Install
8.4s avg
Import
2139ms
Disk
70MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.17.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
musl
glibc
py 3.10
✓ —
✓ 11.2s
py 3.11
✓ —
✓ 8.6s
py 3.12
✓ —
✓ 6.7s
py 3.13
✓ —
✓ 7.1s
py 3.9
✕ build_error
✕ build_error
70MB installed
● package 70MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pyatv
import pyatv
scan
from pyatv import scan
from pyatv.core import scan
scan is a top-level function, not in pyatv.core.
connect
from pyatv import connect
from pyatv import interface
The correct way is to use pyatv.connect.
const
from pyatv import const
import pyatv.const
top-level module, import as shown.

Scan for Apple TV devices, connect to the first one found, and send a play/pause command.

import asyncio from pyatv import scan, connect async def example(): devices = await scan(loop=asyncio.get_running_loop(), timeout=5) if not devices: print("No Apple TV found") return atv = devices[0] print(f"Found: {atv.name} at {atv.address}") try: conn = await connect(atv, loop=asyncio.get_running_loop()) print("Connected successfully") # Example: play/pause await conn.remote_control.play_pause() conn.close() except Exception as e: print(f"Connection failed: {e}") asyncio.run(example())
pyatv --version
Debug
Known issues
breakingIn 0.17.0, support for pydantic v1 was dropped. You must have pydantic 2.x installed.
fix
Run: pip install 'pydantic>=2'
affects: >=0.17.0
breakingPython 3.9+ required. Python 3.8 support dropped in 0.16.0.
fix
Upgrade Python to 3.9 or later.
affects: >=0.16.0
deprecatedThe `imghdr` module (via mediafile) was removed in 0.16.0. The library now uses tinytag for metadata.
fix
If you relied on imghdr, reimplement using other means.
affects: >=0.16.0
gotchaOn tvOS 18.4+, connection may fail. Fixed in 0.16.1 but still may appear.
fix
Ensure you are using at least pyatv 0.16.1.
affects: >=0.7.0
gotchaAsync functions require an explicit loop argument; passing coroutines directly to asyncio.wait (allowed in Python <3.11) raises an error in Python 3.11+. Fixed in 0.14.4.
fix
Upgrade pyatv to 0.14.4+ or wrap coroutines in asyncio.create_task.
affects: >=3.11, <0.14.4
gotchaThe pyatv package name on PyPI is `pyatv`, but some users mistakenly import `pyatv` as `pyatv` (correct) or try `pyatv.client`. Only the top-level module is available.
fix
Use `import pyatv` and access submodules like `pyatv.const`.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'scan' from 'pyatv'
Outdated version of pyatv (pre-0.7.0) where scan was not a public top-level function.
fix
Upgrade pyatv: pip install --upgrade pyatv
RuntimeError: TimeoutError raised as AuthenticationError
Known issue in pyatv <0.14.2 where TimeoutError during connection was incorrectly re-raised as AuthenticationError, causing frequent reconfiguration in Home Assistant.
fix
Upgrade to pyatv 0.14.2 or later.
TypeError: object dict can't be used in 'await' expression
Trying to use pyatv functions without async/await context or passing coroutines to asyncio.wait incorrectly.
fix
Ensure all pyatv calls are awaited inside an async function, and on Python 3.11+ use asyncio.create_task for coroutines passed to asyncio.wait.
ModuleNotFoundError: No module named 'pydantic'
pydantic is a required dependency missing from the environment.
fix
Install both pyatv and pydantic: pip install pyatv pydantic>=2
Upgrade
Version history
0.17.0latest on PyPI · released Jan 21, 2026
Audit
Dependencies
pydanticrequiredRequired; version 1 dropped in 0.17.0, must use pydantic 2.x.
Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
pyatv — pip install pyatv · libregistry