亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

硒和谷歌瀏覽器驅動程序不會在linux python上運行

硒和谷歌瀏覽器驅動程序不會在linux python上運行

波斯汪 2022-09-13 17:20:16
當我把我的代碼放在理論上看起來應該工作時,我無法讓鉻運行,我甚至遵循了教程,但我不斷得到同樣的錯誤消息。這是我放的代碼:from selenium import webdriver#chromedriver varible with exact location to where its savedchromedriver = "/home/jackmiller/Downloads/chromedriver"#varible of drive to run open up the chrome driver which is located#on my machine as chromedriver varible chromedriverdriver = webdriver.Chrome(chromedriver)#open this websitedriver.get('https://youtube.com')當我在終端中運行代碼時,這是它返回的內容:Traceback (most recent call last):  File "automation.py", line 8, in <module>    driver = webdriver.Chrome(chromedriver)  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__    desired_capabilities=desired_capabilities)  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__    self.start_session(capabilities, browser_profile)  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session    response = self.execute(Command.NEW_SESSION, parameters)  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute    self.error_handler.check_response(response)  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, 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.)它根本沒有打開鉻
查看完整描述

2 回答

?
慕妹3242003

TA貢獻1824條經驗 獲得超6個贊

您是否嘗試過使鉻驅動程序可執行?sudo chmod a+x chromedriver



查看完整回答
反對 回復 2022-09-13
?
牧羊人nacy

TA貢獻1862條經驗 獲得超7個贊

你試過嗎: options.add_argument(“--遠程調試端口=9222”)

從此錯誤報告:https://github.com/SeleniumHQ/selenium/issues/6049

解決方法是指定遠程調試端口作為ChromeOptions的參數,例如:options.add_argument(“-遠程調試端口= 9222”),如果您在容器中運行,請將驅動程序設置為無外設,如sops.headless = True,否則使用類似pyvirtualdisplay之類的東西作為屏幕截圖。


查看完整回答
反對 回復 2022-09-13
  • 2 回答
  • 0 關注
  • 140 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號