Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

set windows async event loop policy to fix playwright async issues

Nick Sweeting02254d810741
diff --git a/browser_use/__init__.py b/browser_use/__init__.py
index 46612163d..c7ec40c0c 100644
--- a/browser_use/__init__.py
+++ b/browser_use/__init__.py
@@ -1,7 +1,14 @@
+import asyncio
+import sys
+
from browser_use.logging_config import setup_logging
setup_logging()
+# Set Windows event loop policy for Playwright compatibility
+if sys.platform.startswith('win'):
+ asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
+
from browser_use.agent.prompts import SystemPrompt
from browser_use.agent.service import Agent
from browser_use.agent.views import ActionModel, ActionResult, AgentHistoryList