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

Headless Chrome无法启动:调试卡在driver.get行求助

Troubleshooting Headless Chrome Stuck on Windows 7 with Python 3.6

Hey there, let's break down why your headless Chrome is getting stuck on driver.get() and how to fix it. Given your setup (Windows 7, Python 3.6), there are a few key areas to check:

  • Chrome Version Compatibility with Windows 7
    Chrome dropped official support for Windows 7 starting with version 109. If you've updated Chrome to the latest version, it's likely incompatible with your OS, which causes headless mode to fail silently.
    Fix: Downgrade Chrome to version 108 (the last version supporting Win7) and make sure your chromedriver matches this exact version—chromedriver and Chrome versions must always align perfectly.

  • Add Critical Headless Mode Flags
    Windows 7's older system components often need extra flags to get headless Chrome running smoothly. Try adding these to your Chrome options:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    
    chrome_options = Options()
    # Use --headless for Chrome <112; for 112+, use --headless=new (but stick to 108 for Win7)
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--no-sandbox")  # Bypasses OS security restrictions (critical for Win7)
    chrome_options.add_argument("--disable-gpu")  # Fixes GPU-related hangs on older systems
    chrome_options.add_argument("--disable-dev-shm-usage")  # Resolves resource limit issues
    chrome_options.add_argument("--window-size=1920,1080")  # Ensures proper page rendering
    
    driver = webdriver.Chrome(options=chrome_options)
    driver.get("your-target-site")
    
  • Match Selenium Version to Python 3.6
    Python 3.6 is end-of-life, and newer Selenium 4.x versions have dropped support for it. Stick to Selenium 3.141.0, which is fully compatible with Python 3.6 and older Chrome versions:

    pip install selenium==3.141.0
    
  • Check Permissions and Chromedriver Path

    • Run your Python script as an administrator (right-click > "Run as administrator")—Win7 sometimes blocks headless processes without elevated rights.
    • Double-check that chromedriver.exe is in your system PATH or explicitly specify its path in the webdriver.Chrome() call:
      driver = webdriver.Chrome(executable_path="C:/path/to/chromedriver.exe", options=chrome_options)
      

内容的提问来源于stack exchange,提问作者Jan Šuman

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 07:27:02