wkeeling / selenium-wire

Extends Selenium's Python bindings to give you the ability to inspect requests made by the browser.
MIT License
1.9k stars 254 forks source link

ImportError: cannot import name 'Timeout' from 'mitmproxy.exceptions' #355

Closed tsoernes closed 3 years ago

tsoernes commented 3 years ago
pip list | grep selenium-wire
selenium-wire                      4.3.3
pip list | grep mitmproxy
mitmproxy                          7.0.0
File "/home/torstein/anaconda3/lib/python3.8/site-packages/seleniumwire/webdriver.py", line 99, in __init__
    self.proxy = backend.create(port=seleniumwire_options.get('port', 0), options=seleniumwire_options)
File "/home/torstein/anaconda3/lib/python3.8/site-packages/seleniumwire/backend.py", line 38, in create
    from . import mitmproxy
File "/home/torstein/anaconda3/lib/python3.8/site-packages/seleniumwire/mitmproxy.py", line 23, in <module>
    from mitmproxy.exceptions import Timeout  # isort:skip

ImportError: cannot import name 'Timeout' from 'mitmproxy.exceptions' (/home/torstein/anaconda3/lib/python3.8/site-packages/mitmproxy/exceptions.py)
tsoernes commented 3 years ago

pip install 'mitmproxy<7.0.0' fixes this problem

wkeeling commented 3 years ago

This is happening due to incompatible APIs in the latest version of mitmproxy 7.0.0.

You should be able to fix by installing version 5.3.0 specifically:

pip install mitmproxy==5.3.0

The mitmproxy backend functionality is going to be removed fairly soon, but I'll make a patch release to fix this in the meanwhile.