Install & Compatibility
Where this runs
tested against v2.0.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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.058s · 18.2MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.050s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Message
✓ from slackblocks import Message
Main entry point for creating Slack messages.
SectionBlock
✓ from slackblocks import SectionBlock
Used to add section blocks to messages.
ImageBlock
✓ from slackblocks import ImageBlock
Used to add image blocks.
DividerBlock
✓ from slackblocks import DividerBlock
Used to add a divider line.
ContextBlock
✓ from slackblocks import ContextBlock
Used to add context elements.
Construct a basic Slack message with a section and an image block, then send using slack_sdk.
import os
from slackblocks import Message, SectionBlock, ImageBlock
message = Message(
channel="#general",
text="Hello, world!",
blocks=[
SectionBlock(text="This is a section block"),
ImageBlock(image_url="https://example.com/image.png", alt_text="Example Image")
]
)
# Send via slack_sdk or similar
from slack_sdk import WebClient
client = WebClient(token=os.environ.get("SLACK_TOKEN", ""))
response = client.chat_postMessage(**message)
print(response)
Errors
Common errors & fixes
TypeError: Object of type SectionBlock is not JSON serializable
Trying to serialize the Message object directly without calling its `build()` or using `**message`
fixUse `**message` when passing to slack_sdk: `client.chat_postMessage(**message)`. Or call `message.build()` to get a dict.
ModuleNotFoundError: No module named 'slackblocks'
slackblocks is not installed or installed in a different environment.
fixRun `pip install slackblocks` in your active environment.
KeyError: 'blocks'
The Slack API requires a 'blocks' field in the payload, but Message without blocks may omit it.
fixAlways provide a `blocks` parameter when constructing Message, even if empty list: `blocks=[]`.
Upgrade
Version history
2.0.0latest on PyPI · released May 15, 2026
Audit
Dependencies
No dependency data recorded yet.