Install & Compatibility
Where this runs
tested against v0.4.4 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.222s · 37.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.5s · import 0.194s · 38MB
35MB installed
● package 35MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
AdbDeviceTcp
✓ from adb_shell.adb_device import AdbDeviceTcp
✗ from adb_shell import AdbDeviceTcp
AdbDeviceTcp is not at the package root; must import from submodule.
AdbDeviceUsb
✓ from adb_shell.adb_device import AdbDeviceUsb
✗ from adb_shell.adb_device import AdbDeviceUsb
AdbCommands
✓ from adb_shell.adb_device import AdbCommands
✗ from adb_shell import AdbCommands
Must import from adb_device submodule.
Connect to an ADB device over TCP and run a shell command.
from adb_shell.adb_device import AdbDeviceTcp
from adb_shell.auth.sign_pythonrsa import PythonRSASigner
# Load the RSA key pair (usually from ~/.android/adbkey and adbkey.pub)
with open('~/.android/adbkey', 'r') as f:
priv = f.read()
with open('~/.android/adbkey.pub', 'r') as f:
pub = f.read()
signer = PythonRSASigner(pub, priv)
device = AdbDeviceTcp('localhost', 5555)
device.connect(rsa_keys=[signer], auth_timeout_s=10)
print(device.shell('echo hello'))
device.close()
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'adb_shell'
Package not installed or installed with wrong name.
fixRun `pip install adb-shell` (the package name on PyPI is adb-shell, not adb_shell).
AttributeError: module 'adb_shell' has no attribute 'AdbDeviceTcp'
Incorrect import path; AdbDeviceTcp is in adb_device submodule.
fixUse `from adb_shell.adb_device import AdbDeviceTcp`.
ConnectionRefusedError: [Errno 111] Connection refused
ADB server not running or device not connected on the specified host/port.
fixEnsure ADB server is running (`adb start-server`) and device is connected (`adb devices`). Verify host and port (default 5555).
Upgrade
Version history
0.4.4latest on PyPI · released Sep 1, 2023
Audit
Dependencies
rsarequiredRequired for ADB authentication
cryptographyrequiredRequired for ADB authentication
aiofilesoptionalRequired for async file operations
asyncsshoptionalExperimental ADB over SSH support