We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
Trying to run the WSGI example on readme doesn't work when runned in any other folder than the one the .env lives.
For example, having a folder with a .env a file named main.py:
import os import dotenv print("Loading file:", os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env')) dotenv.read_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env'))
Running on the same folder works without problems:
$ python main.py Loading file: .env
Moving to another folder, fails:
$ python path/to/main.py Loading file: .env dot_env_example/main.py:5: UserWarning: Not reading .env - it doesn't exist. dotenv.read_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env'))
This can be avoided removing the duplicated os.path.dirname part:
os.path.dirname
$ python path/to/main.py Loading file: path/to/.env
Is the parameter supposed to be entered relative to the main.py folder, or relative to the folder being run?
Cheers!
The text was updated successfully, but these errors were encountered:
I just ran into this issue in my own environment.
Changing dotenv.read_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env'))
dotenv.read_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env'))
to dotenv.read_dotenv(os.path.join((os.path.dirname(__file__), '.env'))
dotenv.read_dotenv(os.path.join((os.path.dirname(__file__), '.env'))
is what fixed the problem for me.
Hope this helps!
Sorry, something went wrong.
No branches or pull requests
Hello,
Trying to run the WSGI example on readme doesn't work when runned in any other folder than the one the .env lives.
For example, having a folder with a .env a file named main.py:
Running on the same folder works without problems:
Moving to another folder, fails:
This can be avoided removing the duplicated
os.path.dirname
part:Is the parameter supposed to be entered relative to the main.py folder, or relative to the folder being run?
Cheers!
The text was updated successfully, but these errors were encountered: