You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python Selenium脚本报错:无法连接到chromedriver服务

Selenium无法连接chromedriver服务的报错排查与解决

报错信息

File "C:\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 109, in start
raise WebDriverException(f"Can not connect to the Service {self._path}")
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service C:\Users\usernamehere.wdm\drivers\chromedriver\win64\123.0.6312.58\chromedriver-win32/chromedriver.exe

测试代码

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

options = Options()
options.headless = False
options.add_argument("--window-size=1200,576")
options.add_argument("--start-maximized")

service = Service(ChromeDriverManager().install())

driver = webdriver.Chrome(service=service,options=options)

解决思路

  • 修正路径格式:报错路径混合了Windows不兼容的/和\,手动指定路径时统一使用双反斜杠\\或正斜杠/,也可以将ChromeDriverManager的安装目录改为无特殊字符的路径。
  • 处理权限限制:
    • 将chromedriver.exe复制到权限宽松的目录(如D盘自建的chromedriver文件夹),手动指定路径:
      service = Service("D:\\chromedriver\\chromedriver.exe")
      
    • 右键Python脚本选择「以管理员身份运行」,或给chromedriver所在的用户目录添加读写权限。
  • 验证版本匹配:通过chrome://version/查看本地Chrome浏览器版本,确保chromedriver版本与浏览器完全一致。若ChromeDriverManager安装版本不符,手动下载对应版本替换。
  • 规避Admin by Request干扰:临时关闭该工具,或将chromedriver移至不受该工具管控的目录后重新测试。

内容的提问来源于stack exchange,提问作者tom bannister

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 14:17:40