ImportError: cannot import name 'webdriver' from 'seleniumwire'
Fixes the selenium-wire import failure where the package imports but has no webdriver inside. Use when `from seleniumwire import webdriver` raises ImportError naming webdriver. Not for `No module named 'seleniumwire'`.
Either a file named seleniumwire.py in your working directory is shadowing the package, or the install is damaged. Check with python -c "import seleniumwire; print(seleniumwire.__file__)": a project path means rename your file (and clear __pycache__); a site-packages path means python -m pip install --force-reinstall selenium-wire.
The error
ImportError: cannot import name 'webdriver' from 'seleniumwire'Fix it
- Find what got imported
python -c "import seleniumwire; print(seleniumwire.__file__)"Expected: a site-packages path. A project path ending in seleniumwire.py is a shadowing file.
- If shadowed, rename your file
Rename seleniumwire.py to something else, delete __pycache__, then:
python -c "from seleniumwire import webdriver; print('ok')"Expected: prints ok.
- If not shadowed, reinstall
python -m pip install --force-reinstall selenium-wireExpected: the import from step 2 now works. A partial install can leave the package directory without the webdriver module.
When this applies
from seleniumwire import webdriverraises ImportError namingwebdriver- selenium-wire is installed but the name is missing
When it does NOT apply
No module named 'seleniumwire'means nothing is installed (note the pip name has a dash:selenium-wire)cannot import name 'webdriver' from 'selenium'is plain selenium's shadowing trap, different package
Compatibility
selenium-wire 5.x. The documented import is from seleniumwire import webdriver (no dash in the module name).
Why it happens
Two candidates, same as every package: a local seleniumwire.py shadowing the installed package (script directory beats site-packages), or a damaged install missing the webdriver submodule. The __file__ check distinguishes them in one command.
Edge cases
- selenium-wire also ships
seleniumwire.undetected_chromedriver. If THAT import fails instead, the undetected-chromedriver companion package is missing. - Do not
pip install seleniumwire(no dash). The PyPI name isselenium-wire.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.