python安装selenium-wire库失败

python安装selenium-wire库失败怎么办?

pip install selenium-wire

用这个命令安装,但是报ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.错误

img

然后改用,python pip install selenium-wire==4.2.0 --upgrade --ignore-installed selenium-wire但还是报错说依赖不匹配
报错如下

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pyasn1-modules 0.2.2 requires pyasn1<0.5.0,>=0.4.1, but you have pyasn1 0.5.0 which is incompatible.
requests 2.19.1 requires idna<2.8,>=2.5, but you have idna 3.4 which is incompatible.
requests 2.19.1 requires urllib3<1.24,>=1.21.1, but you have urllib3 2.0.4 which is incompatible.

img

pip install selenium-wire==4.2.0 --upgrade --ignore-installed selenium-wire
  1. 换个selenium 版本,多安装几个不同版本的试试
  2. 或者按照提示 一个个换别的库的版本...比如urllib需要小于1.24大于1.21.1版本,但你的版本是2.0太高了,换个低版本

【以下回答由 GPT 生成】

对于这个问题,可以尝试以下解决方案:

  1. 首先,尝试使用--ignore-installed参数再次运行pip install命令,以确保不会出现不能准确确定文件归属导致只有部分卸载的错误:
pip install --ignore-installed selenium-wire
  1. 如果步骤1仍然失败,可以尝试手动卸载certifi包,并重新安装:
pip uninstall certifi
pip install selenium-wire
  1. 如果步骤2还是没有解决问题,可以尝试手动安装依赖项的特定版本,以解决依赖不匹配的问题:
pip install pyasn1==0.4.1 idna==2.7 urllib3==1.23
pip install selenium-wire

希望以上解决方案可以帮助您解决问题。如果上述操作仍然不能解决问题,请告诉我,我将尽力提供更多帮助。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^