> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Python Product Analytics installation Canonical URL: https://posthog.com/docs/product-analytics/installation/python > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host). ## On this page - [Install with the wizard](#install-with-the-wizard) - [Install the package](#install-the-package) - [Initialize PostHog](#initialize-posthog) - [Send events](#send-events) - [Next steps](#next-steps) ## Install with the wizard Run this command in your project directory to add PostHog to your Python project. The wizard detects your framework, installs the SDK, and sets up your first events. `npx @posthog/wizard` Or set it up manually by following the rest of this guide. 1. 1 ## Install the package Required Install the PostHog Python library using pip: Terminal ```bash pip install "posthog<8" ``` 2. 2 ## Initialize PostHog Required Initialize the PostHog client with your project token and host from your project settings: Python ```python from posthog import Posthog posthog = Posthog( project_api_key='', host='https://us.i.posthog.com' ) ``` **Django integration** If you're using Django, check out our [Django integration](https://posthog.com/docs/libraries/django.md) for automatic request tracking. 3. 3 ## Send events Recommended Once installed, PostHog will automatically start capturing events. You can also manually send events to test your integration: Capture custom events by calling the `capture` method with an event name and properties: Python ```python import posthog posthog.capture('user_signed_up', distinct_id='user_123', properties={'example_property': 'example_value'}) ``` 4. 4 ## Next steps Recommended Now that you're capturing events, continue with the resources below to learn what else Product Analytics enables within the PostHog platform. | Resource | Description | | --- | --- | | [Capturing events](https://posthog.com/docs/product-analytics/capture-events.md) | Learn how to capture custom events beyond autocapture | | [Identifying users](https://posthog.com/docs/product-analytics/identify.md) | Associate events with specific users | | [Creating insights](https://posthog.com/docs/product-analytics/insights.md) | Build trends, funnels, and retention charts | | [Group analytics](https://posthog.com/docs/product-analytics/group-analytics.md) | Track events at the company or account level |