{"id":104,"library":"cloudflare-workers","title":"Cloudflare Workers Python SDK","description":"Python SDK for building Cloudflare Workers. Allows writing serverless functions in Python that run on the Cloudflare edge network using Pyodide (CPython compiled to WebAssembly). This is distinct from the 'cloudflare' package which is the API client for managing Cloudflare resources.","status":"active","version":"0.0.8","language":"python","source_language":"en","source_url":"https://github.com/cloudflare/cloudflare-workers-sdk","tags":["cloudflare","workers","serverless","edge","python","pyodide","wasm"],"install":[{"cmd":"pip install cloudflare-workers","lang":"bash","label":"Python"}],"dependencies":[{"reason":"Required for local development, testing, and deploying Workers. Installed via npm, not pip.","package":"wrangler","optional":false}],"imports":[{"wrong":"from cloudflare.workers import Response","symbol":"KeyValueStore","correct":"from cloudflare_workers import KeyValueStore"},{"wrong":"from cloudflare.workers import Response","symbol":"key_value_store","correct":"from cloudflare_workers import key_value_store"}],"quickstart":{"code":"from cloudflare.workers import Response\n\nasync def on_fetch(request, env):\n    return Response('Hello from Python Workers!')\n","lang":"python","description":"Minimal Cloudflare Worker in Python. The on_fetch handler is the entry point for HTTP requests. Deploy with wrangler after configuring wrangler.toml with compatibility_flags = [\"python_workers\"]."},"warnings":[{"fix":"from cloudflare.workers import Response","message":"The import path is 'cloudflare.workers', NOT 'cloudflare_workers'. The pip package name uses a hyphen but the import namespace uses a dot.","severity":"breaking","affected_versions":"all"},{"fix":"Use separate virtual environments if you need both the Workers SDK and the Cloudflare API client.","message":"This package conflicts with the 'cloudflare' PyPI package (the Cloudflare API client). Both occupy the 'cloudflare' namespace. Do not install both in the same environment.","severity":"gotcha","affected_versions":"all"},{"fix":"Check the Pyodide package list for availability. C-extension packages generally won't work unless explicitly ported.","message":"Python Workers run on Pyodide (CPython in WebAssembly). Not all Python packages are available. Only pure-Python packages and select packages with Pyodide builds are supported.","severity":"gotcha","affected_versions":"all"},{"fix":"Always define your handler as 'async def on_fetch(request, env):' not 'def on_fetch(request, env):'.","message":"The handler function must be async. Synchronous handlers will fail silently or raise errors at runtime.","severity":"gotcha","affected_versions":"all"},{"fix":"Add compatibility_flags = [\"python_workers\"] and set main = \"src/entry.py\" in wrangler.toml.","message":"Python Workers require compatibility_flags = [\"python_workers\"] in wrangler.toml and main must point to a .py file. Without this flag, deployment fails.","severity":"gotcha","affected_versions":"all"},{"fix":"Pin your cloudflare-workers version and test thoroughly before upgrading.","message":"Python Workers support is still in open beta. APIs may change between releases without following semver strictly.","severity":"deprecated","affected_versions":"all"},{"fix":"Add 'cloudflare-workers' to your requirements.txt or install via pip: `pip install cloudflare-workers`","message":"The 'cloudflare-workers' package must be installed in your environment for imports like 'from cloudflare.workers import Response' to succeed. Missing the package will result in a ModuleNotFoundError for 'cloudflare'.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"search_vec":"'allow':11 'api':40 'build':8 'client':41 'cloudflar':1,9,21,35,44,46 'compil':27 'cpython':26 'distinct':32 'edg':22,49 'function':14 'manag':43 'network':23 'packag':36 'pyodid':25,51 'python':3,5,16,50 'resourc':45 'run':18 'sdk':4,6 'serverless':13,48 'use':24 'wasm':52 'webassembl':29 'worker':2,10,47 'write':12","created_at":"2026-03-18T02:48:56.742422+00:00","updated_at":"2026-04-16T02:39:17.765543+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":0,"quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"0.0.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://workers.cloudflare.com","github":"https://github.com/dineshsonachalam/cloudflare_workers","docs":null,"changelog":null,"pypi":"https://pypi.org/project/cloudflare-workers/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["aws"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-06-30","next_check":"2026-07-30","install_tag":"stale"}}