How to access Discord Bot token from another python file for Heroku
Ok, I figured it out. After installing python-dotenv, and changing the name of my env file to .env, I was still running into problems when trying to print the TOKEN variable in my main.py file. What eventually ended up fixing it was I moved the .env file to the same directory as my main.py script (before .env was in a separate folder). This fixed it and I was able to grab the variable from .env and print it in main.py. Thanks to all who helped me! I have uploaded my final code from main.py and .env.
import os
import dotenv
from dotenv import load_dotenv
load_dotenv()
token = os.getenv('TOKEN')
print(token)
and .env
TOKEN = qwertyuiopasdfgjklmnbvz