close

PyCharm

This guide will show you how to seamlessly integrate the Doppler CLI with PyCharm Professional and Community Editions.

Prerequisites

Configuration

Because PyCharm uses a custom JetBrains Python debug library, the Doppler CLI cannot be used to run your application.

To work around this, we created the doppler-env package which (when activated with the DOPPLER_ENV environment variable) injects secrets as environment variables into the Python debug process before your application code is run.

Install the doppler-env package in your virtual environment:

doppler-env
pip install doppler-env
pipenv install doppler-env --dev
poetry add doppler-env@latest --dev
📘

Ensure your PyCharm project is configured to use the Python interpreter belonging to this application's virtual environment.

Debug Configuration

Local

Add the required DOPPLER_ENV environment variable to your Debug Configuration:

Screenshot of local debugging

Now configure the Doppler CLI to select the project and config:

doppler setup

Then run your PyCharm Debug Configuration and your secrets will automatically be injected as environment variables into the Python debug process.

Docker Compose

Ensure your local Docker engine is added to PyCharm in the Build, Execution, Deployment section of its preferences.

Image

Make sure the "Connection successful" message appears after adding Docker.

Image

Next, add a new Python Interpreter in the Project settings area of your preferences.

Image

Choose the Docker Compose option for the interpreter, select the Docker engine you created earlier,

Image

Click Apply and then OK.

Image

Select Edit Configurations...

Image

And then add the DOPPLER_ENV environment variable to the configuration.

Image
Image

Finally, choose the Remote Python Interpreter you created earlier from the Python Interpreter dropdown.

Image

Your project should now load secrets from Doppler in Docker Compose and breakpoints should work as expected when running using Debug mode.50

Python Console

Add the required DOPPLER_ENV environment variable to your Python Console settings in Preferences > Build, Execution, Deployment > Console > Python Console.

Screenshot of python console
👍

Awesome Work

Now you know how to use Doppler to supply secrets when developing locally with PyCharm.


Did this page help you?