Questions tagged [python-decouple]

Python decouple is frequently used within Python Web Frameworks (e.g. Django or Flask) to store instance settings, so they can be changed without the need of redeploying the whole project or app.

Decouple claims to work better than enviromental variables. Here's an example:

Let's say you have an envvar DEBUG=False. If you run:

if os.environ['DEBUG']:
    print True
else:
    print False

It will print True, because os.environ['DEBUG'] returns the string "False". Since it's a non-empty string, it will be evaluated as True.

Decouple addresses this caveats by allowing casting of values:

config('DEBUG', cast=bool)

References

25 questions
0
votes
1 answer

Import "decouple" could not be resolved in Python

So I'm trying to import config from the ".env" file via python-decouple but when I try do the import: from decouple import config it returns the error of: Import "decouple" could not be resolved
CharlieW
  • 35
  • 7
0
votes
0 answers

ModuleNotFoundError: No module named 'decouple' while creating a flask URL shortener app

I ran into this error while trying to initiate my database, even though I have python-decouple installed. I am new to programming so I will attach images of the error to see if anybody can figure out exactly what the problem is. This is the…
0
votes
1 answer

Why pytest (pytest-django) doesn't have access to .env variables through decouple which regular django files access as normal?

I have a django project and I'm setting up my testing environment with pytest and pytest-django. Previously, I have set up my environment variables like DB_HOST using decouple module. These variables work fine when they are used by regular django…
LLaP
  • 2,528
  • 4
  • 22
  • 34
0
votes
0 answers

I dont know why my project in django return ModuleNotFoundError: No module named -

I have a django project with gunicorn and nginx. Everything was going well, but when I installed decouple for the environment variables, it started to give me the following errors: Traceback (most recent call last): File…
vien2
  • 23
  • 5
0
votes
2 answers

django db settings into a .env file with decouple

I want to put my django database settings into a .env file for production. While I successfully wrote SECRET KEY and DEBUG in my .env file, when I try to do the same thing for my database settings, I get an error in the webapp. Here is the way I…
Murcielago
  • 905
  • 1
  • 8
  • 30
0
votes
2 answers

python-decouple | The SECRET_KEY setting must not be empty

The project was created using Django 3.1.1. It was recently updated it to Django 3.1.4 and it worked fine. Afterwards, python-decouple 3.3 was installed and it also worked fine. We deleted our testing database (on purpose) to see if everything was…
Ro Segura
  • 67
  • 9
0
votes
1 answer

Django separate settings and .env files (python-decouple): the specified path was not found for static files

I have developed a Django Project and try to manage different configuration (dev and prod) and .env using python-decouple. Below my project architecture and different config files. Maybe I misunderstand but in my comprehension : I have differents…
SLATER
  • 613
  • 9
  • 31
0
votes
2 answers

How to get python-decouple to work on a live server?

I can't seem to get python-decouple to work on a live server. I have a Django project in which python-decouple is used to separate my important variables such as secret key, debug, database vars, and so on in a .env file. When the project is run…
kingx26
  • 25
  • 2
  • 8
0
votes
1 answer

Integrating python-decouple with PRAW?

I've been trying to see if I can use python-decouple to place my bot credentials on a separate .env file. Auth method is basically right off the praw doc: reddit = praw.Reddit( client_id=config('CLIENT_ID'), …
-2
votes
2 answers

Im having trouble getting python-decouple to work

pip install python-decouple from decouple import config ModuleNotFoundError: No module named 'decouple' print(API_USERNAME=config('first_name')) keep getting this error even after i installed it correctly, and i…
Stack Ty
  • 51
  • 7
1
2