Selenium似乎无法正常启动,继续引发**selenium.common.exceptions.WebDriverException:留言:**有人知道如何修复吗?
关于我的设置信息
Mac M1 pro
Chrome version: 107.0.5304.87
ChromeDriver: 107.0.5304.62
selenium version: 4.5.0
首先,我尝试下载的webdriver手册.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
s = Service('/Users/itsmeleah/code/itsmeleahh/Get-Taobao-Data/chromedriver')
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
driver = webdriver.Chrome(service=s, options=chrome_options)
driver.get('https://www.google.com')
日志:
Traceback (most recent call last):
File "/Users/itsmeleah/code/itsmeleahh/Get-Taobao-Data/scraping_test.py", line 11, in <module>
driver = webdriver.Chrome(service=s, options=chrome_options)
File "/Users/itsmeleah/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/Users/itsmeleah/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 92, in __init__
super().__init__(
File "/Users/itsmeleah/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 272, in __init__
self.start_session(capabilities, browser_profile)
File "/Users/itsmeleah/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 364, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Users/itsmeleah/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "/Users/itsmeleah/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 207, in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:
Sencondly,我用chromedrive管理器,仍然得到同样的错误
第一个
执行代码后没有弹出窗口,我也试图关闭现有的chrome窗口以避免冲突,但仍然不起作用。
1条答案
按热度按时间bq3bfh9z1#
确保您已安装chrome浏览器。
brew install google-chrome
确保运行最新版本的selenium和webdriver_manager。
python3 -m pip install --upgrade selenium webdriver_manager
删除所有现有的
rm -rf ~/.wdm
下载,然后再试一次。请确定不要以root身份执行您的指令码。