我在Linux下使用pip安装时出现报错:

Exception:
Traceback (most recent call last):File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in mainstatus = self.run(options, args)File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in runwb.build(autobuilding=True)File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in buildself.requirement_set.prepare_files(self.finder)File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_filesignore_dependencies=self.ignore_dependencies))File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prepare_filerequire_hashesFile "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in populate_linkself.link = finder.find_requirement(self, upgrade)File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requirementall_candidates = self.find_all_candidates(req.name)File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_candidatesfor page in self._get_pages(url_locations, project_name):File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pagespage = self._get_page(location)File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_pagereturn HTMLPage.get_page(link, session=self.session)File "/usr/lib/python2.7/dist-packages/pip/index.py", line 792, in get_page"Cache-Control": "max-age=600",File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 501, in getreturn self.request('GET', url, **kwargs)File "/usr/lib/python2.7/dist-packages/pip/download.py", line 386, in requestreturn super(PipSession, self).request(method, url, *args, **kwargs)File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 488, in requestresp = self.send(prep, **send_kwargs)File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/sessions.py", line 609, in sendr = adapter.send(request, **kwargs)File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 47, in sendresp = super(CacheControlAdapter, self).send(request, **kw)File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/adapters.py", line 423, in sendtimeout=timeoutFile "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/connectionpool.py", line 643, in urlopen_stacktrace=sys.exc_info()[2])File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/util/retry.py", line 315, in incrementtotal -= 1
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

错误的解决方法

网上有一个错误的解决方案

pip install --upgrade pip

运行这个命令后,进行pip安装会报另外一个错:

Traceback (most recent call last):File "/usr/bin/pip", line 9, in <module>from pip import main
ImportError: cannot import name main

解决方法是重新安装pip,如:

python -m pip uninstall pip && sudo apt install python-pip --reinstall

或者可以修改/usr/bin/pip文件,

from pip import main

改为

from pip._internal import main

正确的解决方案

使用如下命令

python -m pip install --upgrade pip
python -m pip install xxx

解决pip安装时出现报错TypeError: unsupported operand type(s) for -=: ‘Retry‘ and ‘int‘相关推荐

  1. Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

    Python PIP Install throws TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'

  2. python报错TypeError: unsupported operand type(s) for -: ‘decimal.Decimal‘ and ‘float‘的解决方法

    问题描述 在编写python代码时,进行小数位相减时出现 TypeError: unsupported operand type(s) for -: 'decimal.Decimal' and 'fl ...

  3. 预测数据时数据类型是object导致报错TypeError: unsupported operand type(s) for -: ‘str‘ and ‘float‘

    解决方法 更换数据类型: data:pd.DataFrame = data.astype('int64') # 或是: data:pd.DataFrame = data.astype('float') ...

  4. pycharm中python调用百度aip所遇问题解决方案记录:pip安装时版本报错以及aip导入时报错no module named aip/requests)

    pycharm中python调用百度aip所遇问题解决方案记录:pip安装时版本报错以及aip导入时报错no module named aip/requests pip安装时版本报错 pip升级后安装 ...

  5. pip问题:windows环境pip安装时一直报错Could not fetch URL

    windows环境pip安装时一直报错Could not fetch URL 可能是url的来源的问题,换成了国内的pip源就可以正常安装了,我使用的是: pip install opencv-pyt ...

  6. 解决Python中sum函数出现的TypeError: unsupported operand type(s) for +: 'int' and 'list'错误问题

    当在Python中运行sum函数时,会出现"TypeError: unsupported operand type(s) for +: 'int' and 'list'"这样的问题 ...

  7. 踩坑中:TypeError: unsupported operand type(s) for /: 'str' and 'int'

    在网上查看了很多博客,首先从报错提示来讲TypeError: unsupported operand type(s) for /: 'str' and 'int',明确了是类型错误:不支持操作类型为整 ...

  8. 解决pip安装whl文件报错问题

    问题描述 1.问题一 pip安装whl文件报错,提示: ERROR: tensorflow-1.13.1-cp37-cp37m-linux_x86_64-gcc8.whl is not a suppo ...

  9. 解决pandas(Python)的报错:unsupported operand type(s) for -: ‘datetime.date’ and ‘Timestamp’

    在使用Pandas包的时候,遇到时间加减出现的报错 'datetime.date'是datetime的一种时间格式: 'Timestamp'(注意是大写的字母)是Pandas的一种时间格式. 这两个虽 ...

最新文章

  1. 2018年这些UI设计趋势正在流行,跟上必拿高薪!
  2. python selenium 自动登录_windows7 python3.63使用selenium+webdriver 实现自动登录使用过程...
  3. IDEA開發 java web 初步
  4. 使用pymc3可能遇到的问题及解决方法
  5. 95-10-030-启动-deamon定时任务
  6. 1000道Python题库系列分享九(31道)
  7. 【IT笔试面试题整理】二叉搜索树转换为双向链表
  8. IIS 7.0 SSL 部署指南
  9. Dart基础第11篇:抽象类 多态 以及接口
  10. 网络核心之数据交换-电路交换
  11. sqlserver2005身份验证
  12. 软考:系统分析师考试大纲
  13. 超市密码箱c语言程序,超市存包系统C语言.doc
  14. 一眼就吸引人的网名「引人注目」
  15. 【单片机】51单片机使用总结
  16. 数据治理:数据质量管理策略!
  17. Java和JDK版本的关系
  18. ISRC活动来袭,快来领福利!
  19. 基于堆优化算法的函数寻优算法
  20. 【MATLAB图像融合】[14]PCNN脉冲耦合神经网络代码分享

热门文章

  1. java代码(dex)注入
  2. c语言包括在方括号中的序号称为,自考《高级语言程序设计》知识点总结(四)...
  3. spell_picture第三版终于摆脱了命令行的操作
  4. html中全选按钮代码怎么写,html中的javascript 全选/取消全选操作示例代码
  5. NAR:UNITE真菌鉴定ITS数据库——处理未分类和并行分类
  6. 蚂蚁森林合种计划(2020.10.31,7天有效,每周更新)
  7. PNAS-2018-病原菌在植物免疫下的转录组
  8. Python使用matplotlib可视化散点图、并在可视化图像的底部和右边添加边缘直方图、自定义边缘直方图的色彩(Marginal Histogram)
  9. pandas删除dataframe列名称中包含特定字符串的数据列(dropping columns contains specifiec substring in dataframe)
  10. R语言可视化包ggplot2绘制线性回归模型曲线实战( Linear Regression Line)