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

Chrome Service报错:'NoneType'对象无'split'属性,求助排查原因

问题

使用Chrome WebDriver Service时,通过WebDriver Manager获取对应版本驱动时出现AttributeError,报错信息为'NoneType' object has no attribute 'split',报错位置在代码第20行的ChromeDriverManager().install()调用处。

完整代码

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from time import sleep
import pandas as pd


URL = "https://iol.invertironline.com/mercado/cotizaciones/argentina/obligaciones%20negociables"
URL2 = "https://www.byma.com.ar/tipo/obligaciones-negociables/"

# Create webdriver object
# driver = webdriver.Chrome()
options = Options()
options.add_experimental_option("detach", True)
#options.add_argument("--headless")
# selenium 4
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
# Get the website
driver.get(URL)

# Make Python sleep for some time
sleep(2)
# Read and Convert Web table into data frame
select = Select(driver.find_element(By.NAME, 'cotizaciones_length'))
# select by value
select.select_by_value('-1')

table = pd.read_html(driver.find_element(
    By.XPATH, "//table[@id='cotizaciones']").get_attribute('outerHTML'))[0]

print(table)
# print(len(table))

报错栈

AttributeError 'NoneType' object has no attribute 'split'   File "C:\Inversiones\prueba2.py", line 20, in <module>
    driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'split'
原因分析与解决办法
  • Chrome版本检测失败:WebDriver Manager需要读取本地Chrome的版本号来匹配驱动,若检测不到Chrome版本(返回None),后续执行split处理版本号时就会报错。

    • 处理:确认Chrome已正确安装且在系统PATH中可被识别;或手动指定Chrome版本,示例:ChromeDriverManager(version="118.0.5993.70").install()(替换为你的Chrome实际版本)。
  • WebDriver Manager版本兼容问题:旧版webdriver-manager与Selenium 4.x不兼容,导致获取驱动逻辑出错返回None。

    • 处理:升级webdriver-manager到最新版,执行命令:pip install --upgrade webdriver-manager。
  • 网络或镜像源问题:WebDriver Manager无法从默认源获取驱动信息,导致返回None。

    • 处理:若网络受限,可更换国内镜像源,示例:ChromeDriverManager(url="https://registry.npmmirror.com/-/binary/chromedriver/").install();同时检查网络连接是否正常。
  • 权限不足:程序无权限读取Chrome安装目录的版本信息,或无权限写入驱动文件到本地路径。

    • 处理:以管理员身份运行Python脚本;或手动指定驱动下载路径,确保路径具备读写权限。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 16:42:48