Questions tagged [python-dotenv]

For questions related to `python-dotenv` library which reads the key-value pair from `.env` file and adds them to the environment variable.

Library Pypi page: https://pypi.org/project/python-dotenv/

There are plenty of alternative implementations: https://pypi.org/search/?q=dotenv

Other runtimes:

39 questions
12
votes
2 answers

import "dotenv" could not be resolved

I am making a program in python that I plan to host on github. I have a .env file containing an api token. I tried to import it into my code like so: first i installed the python-dotenv library by typing pip install python-dotenv in the command…
trs-k3tchup
  • 239
  • 1
  • 2
  • 13
12
votes
3 answers

How do I use .env in Django?

My goal is to email using Python Django without having my email password being shown in the actual code. After some research, I guess I can store my password in an .env file and then access the password from the .env file. So, I currently have an…
usernaame001
  • 129
  • 1
  • 1
  • 9
8
votes
1 answer

Google Cloud Run does not load .env file

I spend the last couple of days trying to find what I have done wrong but I am still not able to figure out because I am able to run the app locally using flask run and also using Docker using docker-compose up --build. Source code is here My issue…
8
votes
2 answers

How to define lists in python dot env file?

In Fast API documentation it is recommended to use .env to load the config. Only that it only supports string as far as I understand it. from fastapi import FastAPI from pydantic import BaseSettings class Settings(BaseSettings): api_tokens =…
Houman
  • 64,245
  • 87
  • 278
  • 460
3
votes
1 answer

Why are the variables inside my .env file resetting to the original file even after changing it from inside my Python script?

I'm trying to implement a checkpoint mechanism for my original script with the following structure: import os import sys from dotenv import load_dotenv def main(): load_dotenv() checkpoint = int(os.getenv('CHECKPOINT')) if checkpoint…
tblaze
  • 138
  • 10
3
votes
2 answers

no module named "dotenv" in visual studio code

I have seen this question about 5 times before, I have tried every solution there, I have tried uninstalling python-dotenv, reinstalling it, using pip, pip3, using pip3 -m install..., I don't have "dotenv" (the one without python) by itself, I'm not…
Heidar-An
  • 89
  • 2
  • 11
2
votes
1 answer

How to fix error while installing dotenv and uvloop

I am trying to install few modules specifically dotenv using pip in python But I got an error I have tried updating pip version and updating setuptool but problem still exist. I tried to install dotenv using pip it showed installing message for few…
2
votes
4 answers

I can't import dotenv from python-dotenv

Windows, Visual studio, django. I tried to install python-dotenv: https://pypi.org/project/python-dotenv/#getting-started. But when I want to import this command, I get error: Import "dotenv" could not be resolvedPylancereportMissingImports. I made…
1
vote
1 answer

Flask is not reacting to the FLASK_ENV variable setting

I am trying to activate debug mode in Flask. What I have tried so far: set FLASK_ENV=development directly in Windows cmd pip installed python-dotenv successfully and set FLASKENV=development in .env file ensured that there is no dotenv package…
JeffP
  • 539
  • 1
  • 5
  • 19
1
vote
3 answers

OpenAI from Langchain requires "openai_api_key" even though it is loaded

this is my code: import os from dotenv import load_dotenv,find_dotenv load_dotenv(find_dotenv()) print(os.environ.get("OPEN_AI_KEY")) from langchain.llms import…
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
1
vote
0 answers

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte; Python-dotenv

After cloning a personal Django project from Github on to my computer, some environment variables were written to a .env file. The variables encompass a Django generated SECRET_KEY surrounded my single quotes and setting DEBUG to a string of…
binny
  • 649
  • 1
  • 8
  • 22
1
vote
4 answers

VS Code not recognizing .env file inside workspace folder (.venv)

I'm trying to set environment variables within a Python virtual environment in VS Code (mostly for API keys). The VS Code documentation here: https://code.visualstudio.com/docs/python/environments suggests that Python will automatically detect a…
1
vote
1 answer

Select different dataset when testing | Separate test from production

This question is partly about how to test external dependencies (a.k.a. integration tests) and partly how to implement it with Python for SQL with BigQuery in specific. So answers only about 'This is how you should do integration tests' are very…
JeroenDV
  • 125
  • 2
  • 14
1
vote
1 answer

Python Firebase Admin SDK, Illegal Firebase credential provided

I'm trying initialising Firebase Admin SDK using .env file on a Django app and I get the following error: Illegal Firebase credential provided. App must be initialized with a valid credential instance the initialisation code: from dotenv import…
B. Mohammad
  • 2,152
  • 1
  • 13
  • 28
1
vote
0 answers

Python can't find module 'dotenv'?

when I try importing load_dotenv from dotenv I get the error ModuleNotFoundError: No module named 'dotenv' Tho I already installed dotenv with py -m pip install python-dotenv If I try running that command again I simply get Requirement already…
1
2 3