PyCharm

reading time 5 mins

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:

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.

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

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

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

Click Apply and then OK.

Select Edit Configurations...

And then add the DOPPLER_ENV environment variable to the configuration.

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

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.

πŸ‘

Awesome Work

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