DEV Community

Ethan Wayne
Ethan Wayne

Posted on

HELP WITH PYTHON ERROR

So I am currently making a slack bot using python. I am not extremely familiar with python but still know some stuff. For some reason I keep getting this error. I've tried multiple things and can't seem to figure it out. Here's the code.

client = slack.WebClient(token=os.environ['SLACK_TOKEN'])
File "/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 679, in getitem
raise KeyError(key) from None
KeyError: 'SLACK_TOKEN'

Top comments (2)

Collapse
 
michalslowikowski00 profile image
mislo

Missing env SLACK_TOKEN, that should be set as your environment variable.
There is no such key like SLACK_TOKEN.
KeyError is pretty self explanatory.

Collapse
 
ewayne08 profile image
Ethan Wayne

Thank you!!