# 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/0c/e3/6bd96bc9eff727a05ee792c80087185586929b8d942243813c5f94aac096/posthoganalytics-6.7.14.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.7.14",
"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": "2184cf696b608125cbafed613124b89bc5e982e6c464b6ad5226b6d857b2c24e",
"md5": "e28569be52bc754588211f543224d874",
"sha256": "995c5f59f52fae8e6294a7e080c2ff0660ccbad67baa1b18bf50e08bafc78b8e"
},
"downloads": -1,
"filename": "posthoganalytics-6.7.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e28569be52bc754588211f543224d874",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 141058,
"upload_time": "2025-11-03T12:29:24",
"upload_time_iso_8601": "2025-11-03T12:29:24.159331Z",
"url": "https://files.pythonhosted.org/packages/21/84/cf696b608125cbafed613124b89bc5e982e6c464b6ad5226b6d857b2c24e/posthoganalytics-6.7.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0ce36bd96bc9eff727a05ee792c80087185586929b8d942243813c5f94aac096",
"md5": "9c5bb98c57144e91cc7684fb6081058b",
"sha256": "9a48e28fed698f13d692fbf5d01b269f899e2b59c5a42240b11c4971cb5c25a2"
},
"downloads": -1,
"filename": "posthoganalytics-6.7.14.tar.gz",
"has_sig": false,
"md5_digest": "9c5bb98c57144e91cc7684fb6081058b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 121910,
"upload_time": "2025-11-03T12:29:25",
"upload_time_iso_8601": "2025-11-03T12:29:25.392797Z",
"url": "https://files.pythonhosted.org/packages/0c/e3/6bd96bc9eff727a05ee792c80087185586929b8d942243813c5f94aac096/posthoganalytics-6.7.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-11-03 12:29:25",
"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"
}