Install & Compatibility
Where this runs
tested against v1.0.5 · 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.910 runs
installs and imports cleanly · install 0.0s · import 0.091s · 19.2MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 2.4s · import 0.090s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Slack
✓ from slackweb import Slack
✗ from slackweb import Client
The main class is `Slack`, not `Client`.
This quickstart demonstrates how to initialize the `Slack` client with your webhook URL and send various types of messages, including simple text, messages with custom sender information, and messages with attachments. Ensure `SLACK_WEBHOOK_URL` is set in your environment.
import os
import slackweb
# Get your Slack Incoming Webhook URL from environment variables
# e.g., SLACK_WEBHOOK_URL='https://hooks.slack.com/services/T.../B.../...'
WEBHOOK_URL = os.environ.get('SLACK_WEBHOOK_URL', 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX')
if WEBHOOK_URL == 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX':
print("WARNING: Please set the SLACK_WEBHOOK_URL environment variable to a valid Slack Incoming Webhook URL.")
print("Skipping quickstart execution due to missing URL.")
else:
try:
slack = slackweb.Slack(url=WEBHOOK_URL)
# Send a simple text message
slack.notify(text="Hello from slackweb! This is a test message.")
print("Successfully sent a simple Slack message.")
# Send a message to a specific channel with a username and emoji icon
slack.notify(
channel="#general",
username="My Python Bot",
icon_emoji=":robot_face:",
text="Another message with custom sender info."
)
print("Successfully sent a Slack message with custom sender info.")
# Send a message with an attachment
slack.notify(
attachments=[
{
"title": "Example Attachment",
"text": "This is an attachment with some extra info.",
"color": "#36a64f"
}
]
)
print("Successfully sent a Slack message with an attachment.")
except Exception as e:
print(f"An error occurred: {e}")
print("Please ensure your SLACK_WEBHOOK_URL is correct and accessible.")
Debug
Known issues
gotchaThis library is *only* for Slack Incoming Webhooks. It does not support the full Slack Web API (e.g., chat.postMessage, users.list, RTM API) or Bot Token authentication. For full API access, use `slack_sdk` (the official Python Slack SDK).fixIf you need broader Slack API functionality, switch to the `slack_sdk` library. `pip install slack_sdk`.
affects: All versions
deprecatedPrior to v1.0.3, the `Slack` object could potentially be instantiated without a `url` parameter and set later. As of v1.0.3, it is strongly recommended (and effectively required for immediate use) to pass the webhook URL directly to the constructor.fixAlways initialize `slackweb.Slack` by passing the webhook URL: `slack = slackweb.Slack(url='YOUR_WEBHOOK_URL')`.
affects: <1.0.3 behavior, 1.0.3+
gotchaThe library might not immediately support the newest Slack Block Kit features or advanced authentication methods like OAuth token exchange. Always refer to the official Slack API documentation for the latest webhook payload structure.fixFor complex Block Kit layouts, construct the `blocks` payload as a Python dictionary according to Slack's API docs and pass it directly to `slack.notify(blocks=...)`.
affects: All versions
Errors
Common errors & fixes
AttributeError: 'Slack' object has no attribute 'chat_postMessage'
Attempting to use full Slack Web API methods (like `chat_postMessage`) with the `slackweb` library, which is designed only for incoming webhooks.
fixUse the `slack_sdk` library for full Slack Web API access. If you only need webhooks, use `slack.notify()`.
requests.exceptions.MissingSchema: Invalid URL 'YOUR_WEBHOOK_URL': No schema supplied. Perhaps you meant https://YOUR_WEBHOOK_URL?
The webhook URL provided to `slackweb.Slack` is missing the `http://` or `https://` scheme.
fixEnsure your Slack webhook URL starts with `https://hooks.slack.com/...`.
TypeError: __init__() missing 1 required positional argument: 'url'
You tried to instantiate `slackweb.Slack()` without providing the `url` parameter in versions 1.0.3 and later.
fixPass the webhook URL directly to the constructor: `slack = slackweb.Slack(url='YOUR_WEBHOOK_URL')`.
Upgrade
Version history
1.0.5latest on PyPI · released Jun 23, 2015
Audit
Dependencies
No dependency data recorded yet.