# PostHog Python
<p align="center">
<img alt="posthoglogo" src="https://user-images.githubusercontent.com/65415371/205059737-c8a4f836-4889-4654-902e-f302b187b6a0.png">
</p>
<p align="center">
<a href="https://pypi.org/project/posthog/"><img alt="pypi installs" src="https://img.shields.io/pypi/v/posthog"/></a>
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/posthog/posthog-python">
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/posthog/posthog-python"/>
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/posthog/posthog-python"/>
</p>
Please see the [Python integration docs](https://posthog.com/docs/integrations/python-integration) for details.
## Development
### Testing Locally
We recommend using [uv](https://docs.astral.sh/uv/). It's super fast.
1. Run `uv venv env` (creates virtual environment called "env")
* or `python3 -m venv env`
2. Run `source env/bin/activate` (activates the virtual environment)
3. Run `uv sync --extra dev --extra test` (installs the package in develop mode, along with test dependencies)
* or `pip install -e ".[dev,test]"`
4. you have to run `pre-commit install` to have auto linting pre commit
5. Run `make test`
1. To run a specific test do `pytest -k test_no_api_key`
## PostHog recommends `uv` so...
```bash
uv python install 3.9.19
uv python pin 3.9.19
uv venv
source env/bin/activate
uv sync --extra dev --extra test
pre-commit install
make test
```
### Running Locally
Assuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.
### Releasing Versions
Updates are released automatically using GitHub Actions when `version.py` is updated on `master`. After bumping `version.py` in `master` and adding to `CHANGELOG.md`, the [release workflow](https://github.com/PostHog/posthog-python/blob/master/.github/workflows/release.yaml) will automatically trigger and deploy the new version.
If you need to check the latest runs or manually trigger a release, you can go to [our release workflow's page](https://github.com/PostHog/posthog-python/actions/workflows/release.yaml) and dispatch it manually, using workflow from `master`.
### Testing changes locally with the PostHog app
You can run `make prep_local`, and it'll create a new folder alongside the SDK repo one called `posthog-python-local`, which you can then import into the posthog project by changing pyproject.toml to look like this:
```toml
dependencies = [
...
"posthoganalytics" #NOTE: no version number
...
]
...
[tools.uv.sources]
posthoganalytics = { path = "../posthog-python-local" }
```
This'll let you build and test SDK changes fully locally, incorporating them into your local posthog app stack. It mainly takes care of the `posthog -> posthoganalytics` module renaming. You'll need to re-run `make prep_local` each time you make a change, and re-run `uv sync --active` in the posthog app project.
Raw data
{
"_id": null,
"home_page": "https://github.com/posthog/posthog-python",
"name": "posthoganalytics",
"maintainer": "PostHog",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "PostHog <hey@posthog.com>",
"keywords": null,
"author": "Posthog",
"author_email": "PostHog <hey@posthog.com>",
"download_url": "https://files.pythonhosted.org/packages/90/c7/445cbfb04857b70dd622851edf6dd3cb16840600670932c4f17db6359150/posthoganalytics-6.3.1.tar.gz",
"platform": null,
"description": "# PostHog Python\n\n<p align=\"center\">\n <img alt=\"posthoglogo\" src=\"https://user-images.githubusercontent.com/65415371/205059737-c8a4f836-4889-4654-902e-f302b187b6a0.png\">\n</p>\n<p align=\"center\">\n <a href=\"https://pypi.org/project/posthog/\"><img alt=\"pypi installs\" src=\"https://img.shields.io/pypi/v/posthog\"/></a>\n <img alt=\"GitHub contributors\" src=\"https://img.shields.io/github/contributors/posthog/posthog-python\">\n <img alt=\"GitHub commit activity\" src=\"https://img.shields.io/github/commit-activity/m/posthog/posthog-python\"/>\n <img alt=\"GitHub closed issues\" src=\"https://img.shields.io/github/issues-closed/posthog/posthog-python\"/>\n</p>\n\nPlease see the [Python integration docs](https://posthog.com/docs/integrations/python-integration) for details.\n\n## Development\n\n### Testing Locally\n\nWe recommend using [uv](https://docs.astral.sh/uv/). It's super fast.\n\n1. Run `uv venv env` (creates virtual environment called \"env\")\n * or `python3 -m venv env`\n2. Run `source env/bin/activate` (activates the virtual environment)\n3. Run `uv sync --extra dev --extra test` (installs the package in develop mode, along with test dependencies)\n * or `pip install -e \".[dev,test]\"`\n4. you have to run `pre-commit install` to have auto linting pre commit\n5. Run `make test`\n 1. To run a specific test do `pytest -k test_no_api_key`\n\n## PostHog recommends `uv` so...\n\n```bash\nuv python install 3.9.19\nuv python pin 3.9.19\nuv venv\nsource env/bin/activate\nuv sync --extra dev --extra test\npre-commit install\nmake test\n```\n\n### Running Locally\n\nAssuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.\n\n### Releasing Versions\n\nUpdates are released automatically using GitHub Actions when `version.py` is updated on `master`. After bumping `version.py` in `master` and adding to `CHANGELOG.md`, the [release workflow](https://github.com/PostHog/posthog-python/blob/master/.github/workflows/release.yaml) will automatically trigger and deploy the new version.\n\nIf you need to check the latest runs or manually trigger a release, you can go to [our release workflow's page](https://github.com/PostHog/posthog-python/actions/workflows/release.yaml) and dispatch it manually, using workflow from `master`.\n\n\n### Testing changes locally with the PostHog app\n\nYou can run `make prep_local`, and it'll create a new folder alongside the SDK repo one called `posthog-python-local`, which you can then import into the posthog project by changing pyproject.toml to look like this:\n```toml\ndependencies = [\n ...\n \"posthoganalytics\" #NOTE: no version number\n ...\n]\n...\n[tools.uv.sources]\nposthoganalytics = { path = \"../posthog-python-local\" }\n```\nThis'll let you build and test SDK changes fully locally, incorporating them into your local posthog app stack. It mainly takes care of the `posthog -> posthoganalytics` module renaming. You'll need to re-run `make prep_local` each time you make a change, and re-run `uv sync --active` in the posthog app project.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Integrate PostHog into any python application.",
"version": "6.3.1",
"project_urls": {
"Homepage": "https://github.com/posthog/posthog-python",
"Repository": "https://github.com/posthog/posthog-python"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f97a8299c8be23cbe1951ea901c4ed8bc2b36f1c02403d69eab6418672399f3e",
"md5": "c45de444335dac3111b660bd2b2aa0db",
"sha256": "5505f076abe2f8836df6584d5245182cd0cdf13a5ac2ed45c1d3f5614cbb38a6"
},
"downloads": -1,
"filename": "posthoganalytics-6.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c45de444335dac3111b660bd2b2aa0db",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 116503,
"upload_time": "2025-07-23T09:52:23",
"upload_time_iso_8601": "2025-07-23T09:52:23.776324Z",
"url": "https://files.pythonhosted.org/packages/f9/7a/8299c8be23cbe1951ea901c4ed8bc2b36f1c02403d69eab6418672399f3e/posthoganalytics-6.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "90c7445cbfb04857b70dd622851edf6dd3cb16840600670932c4f17db6359150",
"md5": "175334ce57e9e9d6cda834c80694f5b8",
"sha256": "30ca703d6089bc6ac6e65d7d752a0c028fa2cddad3bbc053f22a527b65de5bd8"
},
"downloads": -1,
"filename": "posthoganalytics-6.3.1.tar.gz",
"has_sig": false,
"md5_digest": "175334ce57e9e9d6cda834c80694f5b8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 98353,
"upload_time": "2025-07-23T09:52:24",
"upload_time_iso_8601": "2025-07-23T09:52:24.802513Z",
"url": "https://files.pythonhosted.org/packages/90/c7/445cbfb04857b70dd622851edf6dd3cb16840600670932c4f17db6359150/posthoganalytics-6.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-23 09:52:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "posthog",
"github_project": "posthog-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "posthoganalytics"
}