fix(browser): strip PYTHONPATH from browser-use child env - #84022
Closed
jklance16 wants to merge 1 commit into
Closed
fix(browser): strip PYTHONPATH from browser-use child env#84022jklance16 wants to merge 1 commit into
jklance16 wants to merge 1 commit into
Conversation
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.
Collaborator
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. |
This was referenced Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows,
browser_exec(Browser Use mode) crashes withModuleNotFoundError: 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
PYTHONPATHto its own site-packages in the parent process. A child Python interpreter honorsPYTHONPATHahead 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
PYTHONPATHin_base_subprocess_env()so the CLI resolves its own dependencies regardless of the host Hermes environment.Verification
scripts/run_tests.shon 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).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.