> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up Python SDK

> Install and initialize the LaunchDarkly Python SDK to start evaluating feature flags in your application.

**Developer**

**Federal docs**

**EU docs**

**Federal docs**

> [!CAUTION]
>
> **LaunchDarkly onboarding is not available in federal environments**
>
> To learn more, read [LaunchDarkly in federal environments](https://launchdarkly.com/docs/home/infrastructure/federal).

Install and initialize the LaunchDarkly Python SDK to start evaluating feature flags in your application.

## Install the package

```shell title="pip" lines wrap theme={null}
pip3 install launchdarkly-server-sdk
```

### Initialize the SDK

```python title="Python SDK initialization" expandable lines wrap theme={null}
import os
import ldclient
from ldclient import Context
from ldclient.config import Config

if __name__ == '__main__':
    # This is your LaunchDarkly SDK key.
    # Never hardcode your SDK key in production.
    ldclient.set_config(Config('YOUR_SDK_KEY'))

    if not ldclient.get().is_initialized():
        print('SDK failed to initialize')
        exit()

    # For onboarding purposes only we flush events as soon as
    # possible so we quickly detect your connection.
    # You don't have to do this in practice because events are automatically flushed.
    ldclient.get().flush()
    print('SDK successfully initialized')
```

> [accordion] Finding your SDK credentials
>
> You can find your server-side SDK keys, mobile keys, and client-side ID on the **SDK keys** page under **Settings**.

To learn more, read [Initialize the client](https://launchdarkly.com/docs/sdk/server-side/python#initialize-the-client) in the Python SDK reference guide.
