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

Selenium报错:'Service'对象无'process'属性求助

解决Selenium中AttributeError: 'Service' object has no attribute 'process'错误

问题代码

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
website = 'https://www.adamchoi.co.uk/overs/detailed'
path = r"C:\Users\User\Downloads\Compressed\chromedriver"
driver = webdriver.Chrome(service=Service(path))
driver.get(website)
driver.quit()

错误日志

Traceback (most recent call last):
File "e:/[ FreeCourseWeb.com ] Udemy - Web Scraping Course in Python - BS4, Selenium and Scrapy/~Get Your Files Here !/Python-Bots-and-Web-Scrapping-Projects/Scraping using selenium/selenium_scrapper.py", line 5, in 
driver = webdriver.Chrome(service=Service(path))
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
super().__init__(
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chromium\webdriver.py", line 103, in __init__
self.service.start()
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 106, in start
PS C:\Windows\System32\WindowsPowerShell\v1.0> & "C:/Program Files/Python38/python.exe" "e:/[ FreeCourseWeb.com ] Udemy - Web Scraping Course in Python - BS4, Selenium and Scrapy/~Get Your Files Here !/Python-Bots-and-Web-Scrapping-Projects/Scraping using selenium/selenium_scrapper.py"
Traceback (most recent call last):
File "e:/[ FreeCourseWeb.com ] Udemy - Web Scraping Course in Python - BS4, Selenium and Scrapy/~Get Your Files Here !/Python-Bots-and-Web-Scrapping-Projects/Scraping using selenium/selenium_scrapper.py", line 5, in 
driver = webdriver.Chrome(service=Service(path))
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
super().__init__(
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\chromium\webdriver.py", line 103, in __init__
self.service.start()
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 106, in start
self.assert_process_still_running()
File "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\selenium\webdriver\common\service.py", line 117, in assert_process_still_running
return_code = self.process.poll()
AttributeError: 'Service' object has no attribute 'process'

解决方法

  • 匹配ChromeDriver与Chrome浏览器版本:ChromeDriver版本必须和本地Chrome浏览器大版本完全一致(如Chrome为120.x,ChromeDriver也要用120.x版本),版本不兼容会导致驱动服务无法正常启动,进而触发该错误。
  • 修正ChromeDriver路径:Windows系统下需指定chromedriver.exe的完整路径,而非压缩包或无后缀的文件名。确保已解压下载的ChromeDriver压缩包,路径指向解压后的可执行文件,例如修改为path = r"C:\Users\User\Downloads\Compressed\chromedriver.exe"。
  • 升级Selenium版本:旧版本Selenium与新版ChromeDriver存在兼容性问题,执行pip install --upgrade selenium升级到最新稳定版。
  • 使用ChromeDriverManager自动管理驱动:避免手动维护路径和版本,安装webdriver-manager后修改代码如下,自动下载匹配的ChromeDriver:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

website = 'https://www.adamchoi.co.uk/overs/detailed'
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get(website)
driver.quit()

内容的提问来源于stack exchange,提问作者Md.Muntasir Mamun

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.05 09:15:30