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

Python使用Selenium报AttributeError:module 'selenium.webdriver'无'Chrome'属性

Hey there, let's tackle this AttributeError you're facing with Selenium and ChromeDriver. I've been through similar hiccups when starting out, so here are the most likely fixes to try out:

常见原因及解决步骤

1. Fix the path escape issue for ChromeDriver

On Windows, the backslash \ in file paths acts as an escape character in Python strings. For example, \S might get parsed as a special character instead of part of your path. Try either of these two fixes:

  • Use a raw string by adding r before the path to avoid escape parsing:
    driver = webdriver.Chrome(r"E:\Selenium\chromedriver_win32\chromedriver.exe")
    
  • Replace single backslashes with double backslashes:
    driver = webdriver.Chrome("E:\\Selenium\\chromedriver_win32\\chromedriver.exe")
    

2. Check compatibility between Selenium and Chrome versions

Selenium 3.11.0 is a fairly old release (from 2018), and it only supports Chrome versions 62 to 64. If your Chrome browser is way newer than that, the mismatched APIs will trigger an AttributeError. Here's how to fix it:

  • Either downgrade Chrome to version 64 or below (not ideal, since browser updates include security patches)
  • Or upgrade Selenium to a version that matches your Chrome version. For Python 3.6.5, you can try the final stable release of Selenium 3.x:
    pip install selenium==3.141.0
    
    If your Chrome is version 80+, you can go for an early Selenium 4.x release (which supports Python 3.6+):
    pip install selenium==4.0.0
    

3. Make sure ChromeDriver's PATH configuration takes effect

Even if you added the ChromeDriver path to your system PATH, you need to restart your IDE or command prompt for the change to apply. You can verify if ChromeDriver is accessible system-wide:

  • Open Command Prompt, type chromedriver, and hit enter. If you see version info and startup logs, the PATH is set correctly. If you get a "command not found" error, double-check the path you added, or simply move chromedriver.exe into your Python's Scripts folder (this path is already in your PATH, so it's a quick workaround).

4. Rule out Python environment conflicts

If you have multiple Python versions installed on your computer, Selenium might be installed in a different environment than the Python 3.6.5 you're using. Verify this:

  • Run pip --version in the terminal where you execute your code. Check if the displayed Python path matches your 3.6.5 installation directory.
  • Run pip show selenium to confirm the installed version is 3.11.0 and the installation path is correct.

If none of these work, sharing the full text of your AttributeError (like whether it says 'module' object has no attribute 'Chrome' or something else) will help narrow down the problem further.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 09:57:47