I'm trying to build a slackbot and retrieve the slack token from a separate .env file. When I run it, I get thrown an error that looks like this:
raise KeyError(key) from None
KeyError: 'SLACK_TOKEN'
The code for the bot (ShoppingListBot.py) is here:
import slack
import os
from pathlib import Path
from dotenv import load_dotenv
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
client = slack.WebClient(token=os.environ["SLACK_TOKEN"])
The code for the .env file (.env) is here:
SLACK_TOKEN="xoxb-1691324762768-1693412284260-RdP0ZQUaQxD9j9mtLlwfNMbD"