gee
08/06/2025, 10:58 AMprefect-client
package. Trying to run the example
from prefect.client.orchestration import get_client
async def query_api():
async with get_client() as client:
limits = await client.read_concurrency_limits(limit=10, offset=0)
print(limits)
query_api()
throws the following error
ImportError: cannot import name 'schemas' from 'prefect.server' (unknown location)
Marvin
08/06/2025, 10:58 AMMarvin
08/06/2025, 10:59 AMbash
pip install prefect-client
2. The correct way to use the client in Prefect 3.x is:
python
from prefect.client import get_client
async def query_api():
async with get_client() as client:
limits = await client.read_concurrency_limits(limit=10, offset=0)
print(limits)
# To run the async function:
import asyncio
asyncio.run(query_api())
Key changes from your original code:
1. Import get_client
directly from prefect.client
instead of prefect.client.orchestration
2. Add the asyncio.run()
wrapper to execute the async function
If you're still getting the error after making these changes, please try the following:
1. Check your Prefect version:
bash
pip show prefect
pip show prefect-client
2. Make sure there are no conflicting installations:
bash
pip uninstall prefect prefect-client
pip install -U prefect prefect-client
The error you're seeing suggests there might be an issue with the installation or version compatibility. The schemas
import error typically occurs when there's a mismatch between the installed packages or when the installation is incomplete.
Let me know if you still encounter issues after trying these solutions, and we can investigate further.gee
08/06/2025, 11:12 AMimport asyncio
from prefect.client import get_client
async def main():
async with get_client() as client:
response = await client.hello()
print(response.json()) # 👋
asyncio.run(main())
still throws an error. Install prefect and prefect-client defeats the purpose of the client only package no?Marvin
08/06/2025, 11:12 AMMarvin
08/06/2025, 11:13 AMexplore_module_offerings
📊 Tools used:
• explore_module_offerings
(8x)
• get_latest_prefect_release_notes
(4x)
• read_github_issues
(4x)
• research_prefect_topic
(4x)
• review_common_3x_gotchas
(4x)
• search_prefect_3x_docs
(4x)gee
08/06/2025, 1:56 PMgee
08/14/2025, 8:45 PM~/.prefect
or env vars for example), prefect will try to run a local prefect server. And obviously running local server with just the client package fails! I fixed my container by setting the URL And key env vars (properly this time)