Install & Compatibility
Where this runs
tested against v3.3.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.062s · 44.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.5s · import 0.054s · 45MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Pusher
✓ from pusher import Pusher
PusherClient
✓ from pusher import Pusher
✗ from pusher.pusher_client import PusherClient
PusherClient is an internal class; the user-facing client is `Pusher` imported directly from the top-level `pusher` package.
Initializes the Pusher client using application credentials (preferably from environment variables) and demonstrates how to trigger an event to a channel and how to authenticate a private or presence channel subscription for a client.
import os
from pusher import Pusher
# Configure Pusher client with environment variables
pusher_client = Pusher(
app_id=os.environ.get('PUSHER_APP_ID', 'YOUR_APP_ID'),
key=os.environ.get('PUSHER_APP_KEY', 'YOUR_APP_KEY'),
secret=os.environ.get('PUSHER_APP_SECRET', 'YOUR_APP_SECRET'),
cluster=os.environ.get('PUSHER_APP_CLUSTER', 'us2'), # e.g., 'us2', 'eu', 'ap2'
ssl=True
)
# --- Example 1: Triggering an event ---
try:
response = pusher_client.trigger(
'my-channel',
'my-event',
{'message': 'hello world'}
)
print(f"Event triggered successfully: {response}")
except Exception as e:
print(f"Error triggering event: {e}")
# --- Example 2: Authenticating a channel subscription (server-side) ---
# This typically happens in a web endpoint receiving a POST request
# from a client, containing socket_id and channel_name.
socket_id = "123.456" # Example socket_id from client
channel_name = "private-my-channel" # Example channel name
user_id = "user-123" # Required for presence channels
user_info = {"name": "John Doe"} # Optional, for presence channels
try:
auth_response = pusher_client.authenticate(
channel=channel_name,
socket_id=socket_id,
custom_data={'user_id': user_id, 'user_info': user_info} # Use custom_data for user-specific info
)
print(f"Authentication response for {channel_name}: {auth_response}")
except Exception as e:
print(f"Error authenticating {channel_name}: {e}")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pusher'
The 'pusher' library has not been installed in the current Python environment or is not accessible on the Python path.
fixInstall the library using pip: `pip install pusher`
AttributeError: module 'pusher' has no attribute 'trigger'
The `trigger` method is a method of an instantiated `Pusher` object, not a top-level function of the `pusher` module itself. This usually happens when a developer tries to call `pusher.trigger()` after `import pusher` without creating an instance.
fixFirst, instantiate the Pusher client, then call `trigger` on the instance:
```python
import pusher
pusher_client = pusher.Pusher(
app_id='YOUR_APP_ID',
key='YOUR_APP_KEY',
secret='YOUR_APP_SECRET',
cluster='YOUR_APP_CLUSTER'
)
pusher_client.trigger('my-channel', 'my-event', {'message': 'hello world'})
``` TypeError: __init__() missing 1 required positional argument: 'app_id'
When initializing the `Pusher` client, required configuration parameters like `app_id`, `key`, `secret`, and `cluster` (or `host`) are missing from the constructor call.
fixEnsure all necessary parameters are provided when creating the Pusher client instance:
```python
pusher_client = pusher.Pusher(
app_id='YOUR_APP_ID',
key='YOUR_APP_KEY',
secret='YOUR_APP_SECRET',
cluster='YOUR_APP_CLUSTER', # Or provide host/port if not using cluster
)
``` Upgrade
Version history
3.3.4latest on PyPI · released Mar 19, 2026
Audit
Dependencies
requestsrequiredDefault HTTP backend for API calls.
aiohttpoptionalOptional HTTP backend for AsyncIO.
cryptographyrequiredCore dependency for secure communication, updated in v3.3.4.
urllib3requiredCore dependency for HTTP requests, updated in v3.3.4.
pynaclrequiredCore dependency, likely for encryption features, updated in v3.3.4.