Skip to content

pywrangler sync uses the wrong site-packages path on Windows #226

Description

@andrewchang90

Summary

On Windows, pywrangler sync does not copy installed dependencies into python_modules/.
That makes local development fail when the Pyodide runtime starts:

ModuleNotFoundError: No module named 'workers'

The same project works on macOS and deploys successfully.

Environment

  • OS: Windows
  • Python: 3.13.14
  • uv: 0.12.5
  • pywrangler / workers-py: 1.16.2

Reproduction

With a Python Worker project that has dependencies:

uv sync
uv run pywrangler dev

pywrangler dev then fails because modules that should have been synced cannot be imported.
python_modules/ is empty, or does not contain the expected packages.

Cause

pywrangler/sync.py chooses the source site-packages directory from the host
operating system:

site_packages_path = (
    f"lib/python{pyv}/site-packages" if os.name != "nt" else "Lib/site-packages"
)

On Windows, this makes it look in:

Lib/site-packages

But this environment targets Pyodide (emscripten/wasm32), and uv installs the packages using the POSIX-style layout:

lib/python<version>/site-packages

The copy step therefore reads from an empty directory and produces an empty python_modules/ directory.

Expected behavior

pywrangler sync should include project dependencies in python_modules/ on Windows, and pywrangler dev should start successfully.

Workaround

Installing directly into the destination avoids the host-dependent site-packages lookup:

uv pip install --target python_modules/ ...

Using the Pyodide-style lib/python<version>/site-packages path also fixes the immediate problem.

The local patch works, but it is overwritten when workers-py is reinstalled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions