> ## 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

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

<View title="Federal docs">
  <Danger>
    **LaunchDarkly onboarding is not available in federal environments**

    To learn more, read <a href="/docs/home/infrastructure/federal">LaunchDarkly in federal environments</a>.
  </Danger>
</View>

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 title="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**.
</Accordion>

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