Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using slack API: "Module slack has no attribute WebClient "

I try to use the slack API to send a message to a workspace, I found this piece of code on their docs but I have an issue with the module slack. This is the code I used:

import os
import slack

client = slack.WebClient(token=os.environ['SLACK_API_TOKEN'])

response = client.chat_postMessage(
    channel='#viktor',
    text="Hello world!")
assert response["ok"]
assert response["message"]["text"] == "Hello world!"

I have put my app token but it does not recognize WebClient... any idea?

like image 825
Viktor.w Avatar asked Aug 01 '19 13:08

Viktor.w


2 Answers

pip install slack
pip install slackclient
like image 169
Dustin Sun Avatar answered Sep 18 '22 01:09

Dustin Sun


Make sure you don't have any user files named slack slack_client.
A simple filename change to something more original solved my problem.

This was my setup:

  • MacOs HS
  • Python 3.7
  • latest (2.4) version of slackclient installed
like image 30
techkuz Avatar answered Sep 18 '22 01:09

techkuz