Ask coding questions

← Back to all posts
.env Variable Key Calling Is Returning None
aritraroy24 (0)

I am trying to run a Twitter bot in replit. So, obviously, it'll require API Keys. I called the API key from the .env file (though I couldn't create that manually by giving the file name. When I tried to create it, it said You cannot create .env files anymore, checkout the environment variable sidebar).
So I found out the environment variable creating option from the sidebar, and it looks like below -

However, to my surprise, when I tried to get the key using my python script, it returned None. My script looks like below -

# Importing modules
import os

# Keys
CONSUMER_KEY = os.getenv('Consumer_Key')

As replit is not private, I can't keep the secret keys open for all. Please provide any solution.

I really appreciate any help you can provide.