使用松弛API:“模块松弛没有属性WebClient”

时间:2019-08-01 13:20:01

标签: python slack-api

我尝试使用Slack API将消息发送到工作区,我在他们的文档中找到了这段代码,但是模块Slack出现了问题。这是我使用的代码:

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!"

我已经放置了我的应用令牌,但是它无法识别WebClient ...任何想法?

3 个答案:

答案 0 :(得分:0)

pip install slack
pip install slackclient

答案 1 :(得分:0)

确保没有名为slack slack_client的用户文件。
一个简单的文件名更改为更原始的名称解决了我的问题。

这是我的设置:

  • MacOs HS
  • Python 3.7
  • 已安装slackclient的最新(2.4)版本

答案 2 :(得分:0)

我使用python-slack-sdk,效果很好。参见https://github.com/slackapi/python-slack-sdk#uploading-files-to-slack

要安装,请运行 #include<stdio.h> int main(void) { int array[10] = { 10,2,9,4,5,6,7,8,3,1 }; /*Implementing Bubble Sort */ int temp; for (int i = 0; i < 10; i++) { for (int j = i; j < 10; j++) { if (array[i] > array[j]) { temp = array[i]; array[i] = array[j]; array[j] = temp; } } } for (int i = 0; i < 10; i++) { printf("%d ", array[i]); } }

上传文件

pip3 install slack_sdk