Skip to content

fix(browser): strip PYTHONPATH from browser-use child env - #84022

Closed
jklance16 wants to merge 1 commit into
NousResearch:mainfrom
jklance16:fix/browser-use-strip-pythonpath
Closed

fix(browser): strip PYTHONPATH from browser-use child env#84022
jklance16 wants to merge 1 commit into
NousResearch:mainfrom
jklance16:fix/browser-use-strip-pythonpath

Conversation

@jklance16

Copy link
Copy Markdown

Problem

On Windows, browser_exec (Browser Use mode) crashes with ModuleNotFoundError: No module named pydantic_core._pydantic_core.

Root cause

The browser-use CLI runs in its own Python environment (uv tool / uvx), but Hermes sets PYTHONPATH to its own site-packages in the parent process. A child Python interpreter honors PYTHONPATH ahead of its own site-packages, so browser-use ends up importing pydantic from the Hermes venv — a CPython-3.11 binary that a 3.12 interpreter cannot load (pydantic_core is a compiled extension, platform/version specific).

Fix

Strip PYTHONPATH in _base_subprocess_env() so the CLI resolves its own dependencies regardless of the host Hermes environment.

Verification

  • scripts/run_tests.sh on the 3 browser-use test files: 63 passed, 0 failed (10 platform-specific failures excluded — they fail identically before/after this change on Windows because they use POSIX shell-script fake CLIs and POSIX path regexes).
  • Manual: env -u PYTHONPATH browser-use --version -> 0.1.8 (fails with the reported error otherwise).

Impact

Windows-only manifestation, but the fix is safe everywhere: the browser-use CLI has never needed the Hermes PYTHONPATH.

The browser-use CLI runs in its own Python environment (uv tool / uvx),
not the Hermes venv. Hermes sets PYTHONPATH to its own site-packages in
the parent process, and a child Python interpreter honors it ahead of
its own site-packages — on Windows this made browser-use import the
Hermes venv's pydantic_core, a CPython-3.11 binary that a 3.12
interpreter can't load, failing with ModuleNotFoundError:
pydantic_core._pydantic_core.

Strip the var in _base_subprocess_env() so the CLI resolves its own
dependencies regardless of the host Hermes environment.
@alt-glitch alt-glitch added type/bug Something isn't working tool/browser Browser automation (CDP, Playwright) platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Aug 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #83471. Both remove inherited PYTHONPATH from the browser-use child environment; #83471 is the earlier, broader fix because it also removes PYTHONHOME.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks @jklance16 — this was a correct, independent fix for the same PYTHONPATH leak, with an excellent root-cause writeup (the 3.11-vs-3.12 pydantic_core ABI detail). #83471 by @n1majne3 arrived a day earlier and also covered PYTHONHOME, so we merged that one via #86371 with first-submitter credit there. Closing this as superseded; the crash class you diagnosed is now fixed on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/browser Browser automation (CDP, Playwright) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants