-
Notifications
You must be signed in to change notification settings - Fork 487
Description
Python Versions tested: 3.10, 3.11, 3.12.10
Environment: Windows (10, 11) in PyCharm interactive console
Affected package versions: 1.0.1+
When using the pycharm interactive console, the following code no longer finds the .env file by default (as of version 1.0.1).
from dotenv import load_dotenv
load_dotenv()
When testing in version 1.0.0, the load_dotenv() function will correctly find the .env file without any additional arguments. In order to successfully load a .env file located within the project's root directory, the following code must be used.
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv(usecwd=True))
From reading the documentation, it suggests that find_dotenv() doesn't use the CWD by default and works based upon the calling file's location. This creates somewhat unexpected behavior for use in pycharm's interactive console. I wouldn't have expected a change in default behavior like this in a patch release.
PyCharm and Env file Notes
- .env file is located in the project's root directory
- PyCharm console is running in the project's root directory