From f5aa767ef1d6e1c1867179f07fafdaa46437180d Mon Sep 17 00:00:00 2001 From: Luoyger <739052349@qq.com> Date: Thu, 27 Apr 2023 12:48:43 +0800 Subject: [PATCH] add --no-sandbox for chrome in url_selenium (#3589) without --no-sandbox param, load documents from url by selenium in chrome occured error below: ```Traceback (most recent call last): File "/data//playgroud/try_langchain.py", line 343, in langchain_doc_loader() File "/data//playgroud/try_langchain.py", line 67, in langchain_doc_loader documents = loader.load() File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/langchain/document_loaders/url_selenium.py", line 102, in load driver = self._get_driver() File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/langchain/document_loaders/url_selenium.py", line 76, in _get_driver return Chrome(options=chrome_options) File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 80, in __init__ super().__init__( File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 104, in __init__ super().__init__( File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__ self.start_session(capabilities, browser_profile) File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute self.error_handler.check_response(response) File "/install/anaconda3-env/envs/python3.10/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Stacktrace: #0 0x55cf8da1bfe3 #1 0x55cf8d75ad36 #2 0x55cf8d783b20 #3 0x55cf8d77fa9b #4 0x55cf8d7c1af7 #5 0x55cf8d7c111f #6 0x55cf8d7b8693 #7 0x55cf8d78b03a #8 0x55cf8d78c17e #9 0x55cf8d9dddbd #10 0x55cf8d9e1c6c #11 0x55cf8d9eb4b0 #12 0x55cf8d9e2d63 #13 0x55cf8d9b5c35 #14 0x55cf8da06138 #15 0x55cf8da062c7 #16 0x55cf8da14093 #17 0x7f3da31a72de start_thread ``` add option `chrome_options.add_argument("--no-sandbox")` for chrome. --- langchain/document_loaders/url_selenium.py | 1 + 1 file changed, 1 insertion(+) diff --git a/langchain/document_loaders/url_selenium.py b/langchain/document_loaders/url_selenium.py index d061d1aebe7a9..339d5ec4b8d9d 100644 --- a/langchain/document_loaders/url_selenium.py +++ b/langchain/document_loaders/url_selenium.py @@ -71,6 +71,7 @@ def _get_driver(self) -> Union["Chrome", "Firefox"]: chrome_options = ChromeOptions() if self.headless: chrome_options.add_argument("--headless") + chrome_options.add_argument("--no-sandbox") if self.executable_path is None: return Chrome(options=chrome_options) return Chrome(executable_path=self.executable_path, options=chrome_options)