dotenv

access environment variables in Python inside many files

access environment variables in Python inside many files Question: if i need to get the value of an environment variables inside many files in the project Python (flask framework) should i use os.environ[‘HOME’] for every use or there is better way? for example: authroutes.py username= os.environ.get("USERNAME") and in routes under posts postsroutes.py username= os.environ.get("USERNAME") Asked …

Total answers: 1

Why I can't access my environment variable from .env file in vscode python?

Why I can't access my environment variable from .env file in vscode python? Question: I am really new to the space so sorry if my questioning is bad or I ask novice questions. also thanks in advance for the repliers! what I am trying to do? I am trying to access my environment variable from …

Total answers: 4

How can we store a JSON credential to ENV variable in python?

How can we store a JSON credential to ENV variable in python? Question: { "type": "service_account", "project_id": "project_id", "private_key_id": "private_key_id", "private_key": "—–BEGIN PRIVATE KEY—–n", "client_email": "email", "client_id": "id", "auth_uri": "uri_auth", "token_uri": "token_urin", "auth_provider_x509_cert_url": "auth_provider_x509_cert_url", "client_x509_cert_url": "client_x509_cert_url" } I tried encoding and decoding the JSON but it didn’t work I even tried using /// in place …

Total answers: 2

Environment Variable not loading with load_dotenv() in Linux

Environment Variable not loading with load_dotenv() in Linux Question: I’m trying to make a discord bot, and when I try to load a .env with load_dotenv() it doesn’t work because it says Traceback (most recent call last): File "/home/fanjin/Documents/Python Projects/Discord Bot/bot.py", line 15, in <module> client.run(TOKEN) File "/home/fanjin/.local/lib/python3.8/site-packages/discord/client.py", line 708, in run return future.result() File …

Total answers: 6

Change Environment Variables Saved In .env File With Python and dotenv

Change Environment Variables Saved In .env File With Python and dotenv Question: I am trying to update .env environment variables with python. With os.environ I am able to view and change local environment variables, but I want to change the .env file. Using python-dotenv I can load .env entries into local environment variables .env File …

Total answers: 1

I have installed python-dotenv but python cannot find it

I have installed python-dotenv but python cannot find it Question: i am using dotenv in a flask project, and have also tested this in a dumbed down test environment as well. I have tried uninstalling and reinstalling etc but the dotenv module cannot be found by python. When starting flask it sees there are some …

Total answers: 4

How do I solve error "dotenv installation error" on pycharm

How do I solve error "dotenv installation error" on pycharm Question: I am trying to install dotenv package on pycharm edu,but keep getting error that reads “AttributeError: module ‘importlib._bootstrap’ has no attribute ‘SourceFileLoader’ “ I tried to solve this using the python terminal by running command “pip install –user dotenv” as root user but still …

Total answers: 2