web-arena-x / webarena

Code repo for "WebArena: A Realistic Web Environment for Building Autonomous Agents"
https://webarena.dev
Apache License 2.0
647 stars 94 forks source link

error when env.reset(options={"config_file": config_file}) #75

Closed yananchen1989 closed 7 months ago

yananchen1989 commented 7 months ago

hello, I encounter an error following the example of [Quick Walkthrough] part:

when executing obs, info = env.reset(options={"config_file": config_file})

there is error:


Error Traceback (most recent call last) Cell In[2], line 9 7 # prepare the environment for a configuration defined in a json file 8 config_file = "config_files/0.json" ----> 9 obs, info = env.reset(options={"config_file": config_file})

File <@beartype(browser_env.envs.ScriptBrowserEnv.reset) at 0x7f63a376ae60>:49, in reset(beartype_func, __beartype_conf, beartype_get_violation, beartype_object_140065920987520, beartype_object_7615744, *args, **kwargs)

File ~/benchmark/webarena/browser_env/envs.py:203, in ScriptBrowserEnv.reset(self, seed, options) 201 config_file = Path(options["config_file"]) 202 if config_file.exists(): --> 203 self.setup(config_file=config_file) 204 else: 205 raise ValueError(f"Config file {config_file} does not exist.")

File <@beartype(browser_env.envs.ScriptBrowserEnv.setup) at 0x7f63a376ab90>:35, in setup(beartype_func, __beartype_conf, beartype_get_violation, beartype_object_140065920987392, beartype_object_7615744, *args, **kwargs)

File ~/benchmark/webarena/browser_env/envs.py:128, in ScriptBrowserEnv.setup(self, config_file) 126 self.context_manager = sync_playwright() 127 self.playwright = self.context_manager.enter() --> 128 self.browser = self.playwright.chromium.launch( 129 headless=self.headless, slow_mo=self.slow_mo 130 ) 132 if config_file: 133 with open(config_file, "r") as f:

File ~/anaconda3/envs/webarena/lib/python3.10/site-packages/playwright/sync_api/_generated.py:14488, in BrowserType.launch(self, executable_path, channel, args, ignore_default_args, handle_sigint, handle_sigterm, handle_sighup, timeout, env, headless, devtools, proxy, downloads_path, slow_mo, traces_dir, chromium_sandbox, firefox_user_prefs) 14370 def launch( 14371 self, 14372 *, (...) 14393 ] = None 14394 ) -> "Browser": 14395 """BrowserType.launch 14396 14397 Returns the browser instance. (...) 14484 Browser 14485 """ 14487 return mapping.from_impl(

14488 self._sync( 14489 self._impl_obj.launch( 14490 executablePath=executable_path, 14491 channel=channel, 14492 args=mapping.to_impl(args), 14493 ignoreDefaultArgs=mapping.to_impl(ignore_default_args), 14494 handleSIGINT=handle_sigint, 14495 handleSIGTERM=handle_sigterm, 14496 handleSIGHUP=handle_sighup, 14497 timeout=timeout, 14498 env=mapping.to_impl(env), 14499 headless=headless, 14500 devtools=devtools, 14501 proxy=proxy, 14502 downloadsPath=downloads_path, 14503 slowMo=slow_mo, 14504 tracesDir=traces_dir, 14505 chromiumSandbox=chromium_sandbox, 14506 firefoxUserPrefs=mapping.to_impl(firefox_user_prefs), 14507 ) 14508 ) 14509 )

[... skipping hidden 1 frame]

File ~/anaconda3/envs/webarena/lib/python3.10/site-packages/playwright/_impl/_browser_type.py:93, in BrowserType.launch(self, executablePath, channel, args, ignoreDefaultArgs, handleSIGINT, handleSIGTERM, handleSIGHUP, timeout, env, headless, devtools, proxy, downloadsPath, slowMo, tracesDir, chromiumSandbox, firefoxUserPrefs) 90 params = locals_to_params(locals()) 91 normalize_launch_params(params) 92 browser = cast( ---> 93 Browser, from_channel(await self._channel.send("launch", params)) 94 ) 95 self._did_launch_browser(browser) 96 return browser

File ~/anaconda3/envs/webarena/lib/python3.10/site-packages/playwright/_impl/_connection.py:61, in Channel.send(self, method, params) 60 async def send(self, method: str, params: Dict = None) -> Any: ---> 61 return await self._connection.wrap_api_call( 62 lambda: self.inner_send(method, params, False) 63 )

File ~/anaconda3/envs/webarena/lib/python3.10/site-packages/playwright/_impl/_connection.py:461, in Connection.wrap_api_call(self, cb, is_internal) 459 self._api_zone.set(_extract_stack_trace_information_from_stack(st, is_internal)) 460 try: --> 461 return await cb() 462 finally: 463 self._api_zone.set(None)

File ~/anaconda3/envs/webarena/lib/python3.10/site-packages/playwright/_impl/_connection.py:96, in Channel.inner_send(self, method, params, return_as_dict) 94 if not callback.future.done(): 95 callback.future.cancel() ---> 96 result = next(iter(done)).result() 97 # Protocol now has named return values, assume result is one level deeper unless 98 # there is explicit ambiguity. 99 if not result:

Error: ╔════════════════════════════════════════════════════════════════════════════════════════════════╗ ║ Looks like you launched a headed browser without having a XServer running. ║ ║ Set either 'headless: true' or use 'xvfb-run ' before running Playwright. ║ ║ ║ ║ <3 Playwright Team ║ ╚════════════════════════════════════════════════════════════════════════════════════════════════╝ =========================== logs ===========================

/home/yanan/.cache/ms-playwright/chromium-1055/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-fOeApK --remote-debugging-pipe --no-startup-window pid=257321 [pid=257321][err] [257321:257321:1213/170608.061882:ERROR:ozone_platform_x11.cc(239)] Missing X server or $DISPLAY [pid=257321][err] [257321:257321:1213/170608.061924:ERROR:env.cc(255)] The platform failed to initialize. Exiting. ============================================================ Traceback (most recent call last): File "/home/yanan/anaconda3/envs/webarena/bin/ipython", line 11, in sys.exit(start_ipython()) File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/IPython/__init__.py", line 129, in start_ipython return launch_new_instance(argv=argv, **kwargs) File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/traitlets/config/application.py", line 992, in launch_instance app.start() File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/IPython/terminal/ipapp.py", line 318, in start self.shell.mainloop() File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 888, in mainloop self.interact() File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 873, in interact code = self.prompt_for_code() File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/IPython/terminal/interactiveshell.py", line 812, in prompt_for_code text = self.pt_app.prompt( File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1034, in prompt return self.app.run( File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 978, in run return loop.run_until_complete( File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/asyncio/base_events.py", line 625, in run_until_complete self._check_running() File "/home/yanan/anaconda3/envs/webarena/lib/python3.10/asyncio/base_events.py", line 584, in _check_running raise RuntimeError('This event loop is already running') RuntimeError: This event loop is already running If you suspect this is an IPython 8.15.0 bug, please report it at: https://github.com/ipython/ipython/issues or send an email to the mailing list at ipython-dev@python.org You can print a more detailed traceback right now with "%tb", or use "%debug" to interactively debug it. Extra-detailed tracebacks for bug-reporting purposes can be enabled via: %config Application.verbose_crash=True sys:1: RuntimeWarning: coroutine 'Application.run_async' was never awaited

any advice to solve this ? thanks.

oootttyyy commented 7 months ago

Hi @yananchen1989 This error is saying that playwright is trying to start a graphical browser interface in an environment that doesn't have one. Are you running this on a server by any chance? You can set headless=True here to stop playwright from opening a browser interface to proceed.

yananchen1989 commented 7 months ago

@oootttyyy thanks. it works.