selenium-wire: No module named 'pkg_resources' / blinker._saferef (tested)
from seleniumwire import webdriver fails with ModuleNotFoundError: No module named 'pkg_resources' on a fresh install. Installing setuptools only gets you to No module named 'blinker._saferef'. Tested fix: pip install "setuptools<81" "blinker<1.8".
1. Fresh install: from seleniumwire import webdriver fails
pip install selenium-wire in a fresh Python 3.11 venv installed selenium-wire 5.1.0 (the last release, 2022-10-15), selenium 4.51.0 and blinker 1.9.0, and no setuptools. The script:
from seleniumwire import webdriver
print("import ok")
[... traceback trimmed ...]
from seleniumwire import webdriver
File "site-packages/seleniumwire/webdriver.py", line 8, in <module>
from pkg_resources import parse_version
ModuleNotFoundError: No module named 'pkg_resources'
seleniumwire/webdriver.py line 8 is from pkg_resources import parse_version. pkg_resources ships with setuptools, setuptools 82.0.0 removed it, and selenium-wire does not declare setuptools as a dependency.
2. Install setuptools<81, then the next error: blinker._saferef
$ pip install "setuptools<81"
That installed setuptools 80.10.2. Same script (run with -W ignore):
[... traceback trimmed ...]
from seleniumwire.thirdparty.mitmproxy import optmanager
File "site-packages/seleniumwire/thirdparty/mitmproxy/optmanager.py", line 9, in <module>
import blinker._saferef
ModuleNotFoundError: No module named 'blinker._saferef'
selenium-wire bundles an old copy of mitmproxy that imports blinker._saferef, a private module that blinker 1.8.0 dropped (tested: 1.8.0 and 1.9.0 fail, 1.7.0 works). selenium-wire only requires blinker>=1.4, so a fresh install gets blinker 1.9.0.
3. Working pin set
$ pip install "setuptools<81" "blinker<1.8"
That gave blinker 1.7.0 and setuptools 80.10.2, and the import worked:
site-packages/seleniumwire/webdriver.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
from pkg_resources import parse_version
import ok
Pin both in requirements.txt next to selenium-wire==5.1.0. The warning is harmless for now, but it means the pin only buys time.
4. Longer term
The selenium-wire GitHub repository is archived (read-only), so no release will fix this. For new code, Selenium 4 can read network traffic through Chrome DevTools/BiDi without a proxy. If you need a man-in-the-middle proxy, run mitmproxy itself. Test whichever you choose against your own pages; we only tested the import above.
Same root cause elsewhere: No module named 'pkg_resources' (general fix) · TensorBoard · cx_Oracle.
Frequently asked questions
How do I fix No module named 'blinker._saferef' in selenium-wire?
pip install "blinker<1.8". blinker 1.7.0 worked in our test; 1.9.0 fails.
Is selenium-wire still maintained?
No. Its GitHub repository is archived, and 5.1.0 (2022) is the last release.
Written with AI assistance. Measured on 2026-10-24 on Linux in a fresh uv venv with Python 3.11.17: selenium-wire 5.1.0, selenium 4.51.0, blinker 1.9.0 and 1.7.0, setuptools 80.10.2. Output pasted unedited except shortened paths and marked trims. PlainTables is our extension; selenium-wire is free.