解决安装mitmproxy时提示ERROR: Cannot uninstall 'ruamel-yaml'

mitmproxy是一款支持SSL的HTTP代理,它可以用于调试HTTP通信,发起中间人攻击等。mitmproxy提供了一个控制台接口用于动态拦 截和编辑HTTP数据包。

python3安装mitmproxy

1
pip3 install mitmproxy -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

安装失败,出现如下报错信息

1
2
3
4
Installing collected packages: zstandard, Brotli, ruamel.yaml, mitmproxy
Attempting uninstall: ruamel.yaml
Found existing installation: ruamel-yaml 0.15.87
ERROR: Cannot uninstall 'ruamel-yaml'. 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.

image-20210224123606581

根据提示,需要安装新版本的ruamel-yaml,但是Anaconda3已经安装了 ruamel-yaml,版本是0.15.87

需要进行卸载

卸载出错

解决办法

方法一:强制删除ruamel-yaml

找到安装路径,比如

1
rm -rf C:\software\Anaconda3\Lib\site-packages\ruamel*

然后继续执行安装mitmproxy,若依然报错

使用Everything进行搜索删除,比较干净

image-20210224124747264

重新尝试安装mitmproxy

成功截图

image-20210224125016412

并且pip list查看 发现新版本安装成功

image-20210224124312862

方法二:修改安装命令,忽略已安装的包

1
pip3 install -r requirements.txt -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com --ignore-installed ruamel.yaml