A Poetry plugin that automatically loads environment variables from `.env` files into the environment before Poetry commands are run. It is currently at version 0.2.0 and provides an essential feature for managing project-specific configurations by integrating seamlessly with Poetry's workflow.
poetry self add poetry-dotenv-pluginNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install the `poetry-dotenv-plugin`, define environment variables in a `.env` file, and then access them within a Python script executed using `poetry run`. The plugin automatically loads the variables without explicit code changes.
Update your `pyproject.toml` to use `[tool.poetry.group.dev.dependencies]` for development dependencies, aligning with modern Poetry practices. Refer to Poetry's official documentation on dependency groups.
Be mindful of where you place `.env` files. For projects where `.env` loading is undesirable, consider using the plugin's configuration options (e.g., `POETRY_DONT_LOAD_DOTENV` environment variable or `[tool.dotenv].ignore` in `pyproject.toml`) to disable it for specific projects.
If you need to preserve existing environment variables, ensure you are on version 0.2.0 or newer and configure the plugin to not override them. Consult the plugin's documentation for the specific configuration option (e.g., `[tool.dotenv].override_existing = false` in `pyproject.toml` or `POETRY_DOTENV_OVERRIDE_EXISTING=false` env var).
Ensure the `.env` file is in the project root or specify its path using `POETRY_DOTENV_LOCATION` environment variable or `[tool.dotenv].location` in `pyproject.toml`. Verify the plugin is installed globally with `poetry self show plugins`.
Reinstall the plugin using `poetry self add poetry-dotenv-plugin`. Ensure your Poetry version meets the plugin's requirements (typically Poetry 1.2+ for plugins). Check `poetry self show plugins` to confirm activation.
Review the plugin's default behavior regarding environment variable overriding. If on version 0.2.0+, use `[tool.dotenv].override_existing = false` in `pyproject.toml` or `POETRY_DOTENV_OVERRIDE_EXISTING=false` to prevent overriding existing system variables.