Registry / communication / slackclient

slackclient

JSON →
library2.9.4pypypi✓ verified 21d ago

The `slackclient` library is the legacy Python client for the Slack Web API and RTM API. Version 2.9.4 is the last release, and the project is officially deprecated. Users are strongly advised to migrate to the `slack-sdk` package, which is the actively maintained and officially supported Slack Python SDK. While `slackclient` v2.x shared similar import paths with `slack-sdk` (e.g., `from slack import WebClient`), the `slack-sdk` project has continued development and introduced new features and improvements.

pip install slackclient
INSTALL
IMPORT
SIG · SLACKCLIENT
S
slackclient
communicationpythonv2.9.4
Install
2.9s avg
Import
612ms
Disk
49MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.9.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
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.644s · 69.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.9s · import 0.580s · 30MB
49MB installed
● package 49MB
Code
Verified usage

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

WebClient
from slack import WebClient
RTMClient
from slack.rtm import RTMClient
SlackClient
from slack_sdk import WebClient
from slackclient import SlackClient
The `SlackClient` class was for `slackclient` v1.x. For v2.x and `slack-sdk`, use `WebClient`.

This example demonstrates how to send a message to a Slack channel using the `WebClient` from the `slackclient` library (v2.x). Ensure you have a Slack bot token (`SLACK_BOT_TOKEN`) set as an environment variable or hardcoded for testing. This pattern is similar to `slack-sdk`, but future compatibility and new features are only available in `slack-sdk`.

import os from slack import WebClient # This quickstart is for the legacy `slackclient` v2.x. # It is highly recommended to use `slack-sdk` instead. # Get a Slack bot token from environment variable SLACK_BOT_TOKEN = os.environ.get('SLACK_BOT_TOKEN', 'xoxb-YOUR-TOKEN') if not SLACK_BOT_TOKEN: print("Error: SLACK_BOT_TOKEN environment variable not set.") exit(1) client = WebClient(token=SLACK_BOT_TOKEN) try: # Call the chat.postMessage method using the WebClient response = client.chat_postMessage( channel="#general", # Replace with your channel ID or name text="Hello from `slackclient` (legacy)! Please consider using `slack-sdk` instead." ) print(f"Message sent: {response['ts']}") except Exception as e: print(f"Error sending message: {e}")
Debug
Known issues
deprecatedThe `slackclient` Python package is deprecated. Its last version is 2.9.4. All new development and maintenance occurs in the `slack-sdk` package. You should migrate to `slack-sdk` for active support and new features.
fix
Uninstall `slackclient` (`pip uninstall slackclient`) and install `slack-sdk` (`pip install slack-sdk`). Update your import statements and code to use `slack_sdk` if you were relying on implicit `slackclient` features.
affects: 2.x
breakingMajor API changes occurred between `slackclient` v1.x and v2.x. The `SlackClient` class was removed, and the `WebClient` and `RTMClient` classes were introduced with different constructor arguments and method signatures. This change also introduced the new `from slack import ...` import paths.
fix
Refactor your code to use `WebClient` and `RTMClient` (now part of `slack-sdk`) and adapt to the new method signatures and argument requirements, especially around token handling and API call patterns.
affects: >1.x, <=2.x
gotchaConfusion often arises because `slackclient` v2.x introduced imports like `from slack import WebClient`, which are identical to `slack-sdk`. However, `slackclient` is a distinct (and now deprecated) package from `slack-sdk`. Installing `slackclient` will NOT give you the latest `slack-sdk` features or fixes.
fix
Always explicitly install and use `slack-sdk` (`pip install slack-sdk`) to ensure you're on the actively maintained version. Verify your installed packages with `pip freeze | grep slack`.
affects: 2.x
Errors
Common errors & fixes
AttributeError: 'WebClient' object has no attribute 'chat_postMessage'
The `slackclient` library (v2.x) uses the generic `api_call` method for all Web API requests, unlike the `slack-sdk` which provides direct methods like `chat_postMessage`.
fix
Use the `api_call` method instead: `client.api_call('chat.postMessage', channel='C12345', text='Hello!')`.
ImportError: cannot import name 'SlackClient' from 'slackclient'
In `slackclient` v2.x, the main client class was renamed to `WebClient` and the import path changed. `SlackClient` was used in `slackclient` v1.x.
fix
Update your import statement to `from slack import WebClient` and instantiate with `client = WebClient(token=SLACK_BOT_TOKEN)`.
ModuleNotFoundError: No module named 'slack.errors'
This error occurs when attempting to import `SlackApiError` using the `slackclient` v2.x or `slack-sdk` path, but an older version of `slackclient` (v1.x) is installed, or the package is not installed correctly.
fix
Ensure `slackclient` v2.x (or `slack-sdk`) is installed via `pip install slackclient` (or `pip install slack-sdk`) and use `from slack.errors import SlackApiError`.
TypeError: api_call() missing 1 required positional argument: 'method'
The `api_call` method in `slackclient` requires a string representing the Slack Web API method (e.g., `'chat.postMessage'`) as its first argument.
fix
Provide the API method name as the first argument, for example: `client.api_call('chat.postMessage', channel='C12345', text='Hello!')`.
TypeError: __init__() missing 1 required positional argument: 'token'
The `WebClient` (and `SlackClient` in v1.x) constructor requires an API token string for authentication with the Slack API.
fix
Provide your Slack bot or user token when initializing the client: `client = WebClient(token="xoxb-YOUR-TOKEN")`.
Upgrade
Version history
2.9.4latest on PyPI · released Apr 22, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
OpenAI (training)
1
Resources
slackclient — pip install slackclient · libregistry