Ferchau Gupta
06/16/2026, 5:28 AMMarvin
06/16/2026, 5:28 AMMarvin
06/16/2026, 5:31 AMprefect_test_harness exercises Prefect async internals, and your environment is probably using a newer anyio version where TaskGroup gained a new required abstract method: create_task.
Prefect has an internal class called GatherTaskGroup that subclasses anyio.abc.TaskGroup. If that Prefect version does not implement the new create_task method, Python raises:
text
TypeError: Can't instantiate abstract class GatherTaskGroup with abstract method create_task
So the usual reason is:
Your installed Prefect version is incompatible with your installed anyio version.
What to check
Run:
bash
pip show prefect anyio
If you see a very recent anyio version, that’s the likely trigger.
Typical fix
Try pinning anyio to an earlier compatible version, for example:
bash
pip install "anyio<4.14.0"
or add a constraint in your project config.
You can also try upgrading Prefect to the latest release in case a fix has already landed:
bash
pip install -U prefect
Recommended order
1. Upgrade Prefect
2. If it still fails, pin anyio<4.14.0
Why it shows up in tests
prefect_test_harness spins up Prefect testing infrastructure and touches async orchestration code paths that instantiate this task group, so the incompatibility often appears there first.
Helpful links
- Prefect docs: Prefect documentation
- Prefect releases: Prefect release notes
If you want, I can help you figure out the exact compatible version pair for your current Prefect install.