Python报错TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

问题1:TypeError: unsupported operand type(s) for -=: ‘Retry’ and 'int

在Ubuntu系统上运行pip命令(如 pip install xx)时,报错ImportError: cannot import name ‘main‘。

解决办法

根据博客描述,问题是镜像源的问题。解决方法为将pip源更改至国内镜像。可参考博文1博文2解决。博文3叙述更为详尽。
第一步,创建pip.conf文件
mkdir ~/.pip
touch pip.conf
第二步,编辑pip.conf文件
vim ~/.pip/pip.conf
打开编辑器,编辑该文件,参考文章
按下i,I,o,O,a,A,r,R等任何一个字母后进入编辑模式。
复制粘贴

[global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple

输入:wq!,保存退出。

问题2:ImportError: cannot import name ‘main‘

在运行pip install xx 或者 pip --version等时,出现报错:https://www.cnblogs.com/hellojesson/p/8979926.html。

解决办法

解决办法参考博文
第一步,先卸载ubuntu的pip包
sudo apt-get remove python-pip
第二步,安装pip
sudo apt-get install python-pip python-dev build-essential1
第三步,删除原来的/usr/bin/pip
rm /usr/bin/pip
第四步,创建软链接
ln -s /usr/local/bin/pip /usr/bin/pip

关注微信公众号“遥感头号”,获取更多有关python、深度学习、遥感的信息、学习笔记、资料

猜你喜欢

转载自blog.csdn.net/cherry593/article/details/89787421