Search code examples
pythonpycharmslack

AttributeError: module 'slack' has no attribute 'RTMClient'


I getting below error on running my python file slack_rtmClient.py in Pycharm

   C:\Users\A6002043\AppData\Local\Programs\Python\Python38-32\python.exe C:/Users/A6002043/IdeaProjects/iptautobot/slack_rtmClientnew.py
Traceback (most recent call last):
C:\Users\A6002043\AppData\Local\Programs\Python\Python38-32\lib\site-packages\slack\__init__.py
  File "C:/Users/A6002043/IdeaProjects/iptautobot/slack_rtmClientnew.py", line 10, in <module>
    @slack.RTMClient.run_on(event='message')
AttributeError: module 'slack' has no attribute 'RTMClient'

Sample code in slack_rtmClient.py file

import os
import re
from builtins import len, Exception
import slack
import logging
from subprocess import check_output
import datetime
print(slack.__file__)


@slack.RTMClient.run_on(event='message')
def say_hello(**payload):
    try:

Solution

  • You can try this

    1. Open PyCharm.

    2. go to File -> settings -> Project:test(test means your project name) -> select project interpretor -> click add button

    enter image description here

    3. after click add button search slack-rtm-bot then install it.

    finally run the program.

    • Remember slack-rtm-bot installed only this project. if you have started another project based on RTMClient you have to install that interpreter again.