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

求助:在Spyder(Anaconda)中用Selenium遇webdriver_manager模块缺失错误

问题描述

已在Anaconda环境的Spyder中安装了webdriver-manager包,但运行以下脚本时仍触发ModuleNotFoundError:

import time
import random
import urllib.parse
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

错误信息:

runfile('C:/Users/dinez/.spyder-py3/scrapping_db/level_scrapping_rotationalIP1.py', wdir='C:/Users/dinez/.spyder-py3/scrapping_db')
Traceback (most recent call last):

 File C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)
 File c:\users\dinez\.spyder-py3\scrapping_db\level_scrapping_rotationalip1.py:6
    from webdriver_manager.chrome import ChromeDriverManager

ModuleNotFoundError: No module named 'webdriver_manager'
解决方法
  • 确认环境一致性:在Spyder的IPython控制台输入以下命令,查看当前使用的Python解释器路径:

    import sys
    print(sys.executable)
    

    复制该路径,打开命令提示符,运行[复制的路径] -m pip install webdriver-manager,确保包安装在Spyder正在使用的环境中。

  • 通过Anaconda Prompt安装:

    1. 打开Anaconda Prompt,若使用虚拟环境,先执行conda activate 你的环境名称(base环境可跳过此步)。
    2. 执行pip install webdriver-manager完成安装。
  • Spyder内直接安装:
    打开Spyder,依次点击工具 -> 打开命令提示符,在弹出的窗口中直接运行pip install webdriver-manager,安装完成后重启Spyder。

  • 强制重新安装:
    若上述方法无效,尝试执行pip uninstall webdriver-manager && pip install webdriver-manager,确保包文件无损坏。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 22:15:01