簡體   English   中英

selenium.common.exceptions.WebDriverException:消息:Linux 上的 ChromeDriver Selenium Python 服務 /usr/bin/google-chrome 意外退出

[英]selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited with ChromeDriver Selenium Python on Linux

from selenium import webdriver

driver = webdriver.Chrome(executable_path=r'/usr/local/bin/google-chrome')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()

我收到此錯誤:

 File "test.py", line 5, in <module>
    driver = webdriver.Chrome(executable_path=r'/usr/bin/google-chrome')
  File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
    self.service.start()
  File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: 1

我嘗試了互聯網上的其他解決方案,但我嘗試的每個解決方案都收到了一個新錯誤。 我只想使用 python selenium 和 chrome 驅動程序獲取頁面源,我不知道為什么沒有解決方案對我有用,有什么幫助嗎?

我在客戶端 - 服務器中執行此操作,在我的本地即時消息中使用 Windows 並且它的工作良好,但是它的代碼不同......

這個錯誤信息...

selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: 1

...暗示ChromeDriver無法啟動/生成新的瀏覽上下文,Chrome 瀏覽器會話。

看來你已經很接近了。 通過Key executable_path而不是google-chrome二進制executable_path絕對路徑,您需要將ChromeDriver絕對路徑作為Value傳遞。 如此有效,您需要替換以下代碼行:

driver = webdriver.Chrome(executable_path=r'/usr/local/bin/google-chrome')

和:

driver = webdriver.Chrome(executable_path='/path/to/chromedriver')

安裝此軟件包並重試:

apt-get install -y libglib2.0-0=2.50.3-2 \
    libnss3=2:3.26.2-1.1+deb9u1 \
    libgconf-2-4=3.2.6-4+b1 \
    libfontconfig1=2.11.0-6.7+b1

或者您可以安裝鉻瀏覽器:

sudo apt-get install -y chromium-browser

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM