Open tonimelisma opened 2 years ago
Either running from a script, or from the command line, it doesn't accept any pathnames as valid arguments
I think dotenv list
is right in refusing to work with the path of a directory, however, the error message is super confusing. I've attempted to fix this in https://github.com/theskumar/python-dotenv/pull/441. If you want you can try it before I merge it.
However, load_dotenv(dotenv_path="/home/toni/temp", verbose=True) or any other directory falls silently without populating the relevant environment variables.
I'll need more time to fix that one. The behavior of load_dotenv
is not very well defined at the moment and it's not obvious what the right behavior would be.
Happy to provide further debugging information as needed. Your contribution guidelines don't provide any guidance on what's useful. Perhaps that could be something to add, too, to make issue submissions easier to look at.
Your submission is very good, thanks! It's true that some short guidelines could help.
However, load_dotenv(dotenv_path="/home/toni/temp", verbose=True) or any other directory falls silently without populating the relevant environment variables.
I'm having the same issue on Python 3.10.9: load_dotenv()
works perfectly fine, but providing either a relative or absolute filepath or directory path in which a .env
file exists silently fails all the time, even with verbose=True
.
Examples of solutions I tried:
pathlib
and casting the PosixPath object to a String:from pathlib import Path
from dotenv import load_dotenv
dotenv_path = str(Path.cwd().absolute)
load_dotenv(dotenv_path=dotenv_path, verbose=True)
from dotenv import load_dotenv
load_dotenv(dotenv_path=".env", verbose=True)
Alas, neither approach listed here (nor any others I tried) worked. I'm happy to list them all out and provide more information if needed, and potentially try looking into contributing a PR if time/skill allow (but I don't want to make any promise I can't keep on that front).
For reference, this may be related to #104 and #171.
Either running from a script, or from the command line, it doesn't accept any pathnames as valid arguments
In a script,
load_dotenv()
works if I'm in the correct directory. However,load_dotenv(dotenv_path="/home/toni/temp", verbose=True)
or any other directory falls silently without populating the relevant environment variables.The environment:
Happy to provide further debugging information as needed. Your contribution guidelines don't provide any guidance on what's useful. Perhaps that could be something to add, too, to make issue submissions easier to look at.