摘要:没报错但依然无法安装使用再次安装无果感谢大神的分享我才发觉这是一个新手的通用问题树莓派自带的系统附带了一个来自前寒武纪的版本,如果您不想花费数小时来调试与相关的问题,那么就必须升级它。
诸位, 不好意思哈, 请允许我把完整的标题写完(标题不能超过64个有效字符):
记一次解决树莓派下载Django库 ——报错为TypeError: unsupported operand types for -=: "Retry" and "int"的问题(可能该问题Linux系统普遍存在)进日, 玩起了树莓派3B+, 对我这种新手来说, 不搭服务器怎么可以, So, 选择Python的Django库, 尝试各种方法, 失败N次
报错为:
pi@raspberrypi:~ $ sudo pip install django Collecting django Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepa re_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prep are_file require_hashes File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in p opulate_link self.link = finder.find_requirement(self, upgrade) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requir ement all_candidates = self.find_all_candidates(req.name) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_ca ndidates for page in self._get_pages(url_locations, project_name): File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pages page = self._get_page(location) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_page return 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/s essions.py", line 501, in get return self.request("GET", url, **kwargs) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 386, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 488, in request resp = self.send(prep, **send_kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 630, in send history = [resp for resp in gen] if allow_redirects else [] File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 190, in resolve_redirects **adapter_kwargs File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 609, in send r = adapter.send(request, **kwargs) File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachec ontrol/adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/a dapters.py", line 423, in send timeout=timeout File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/con nectionpool.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/uti l/retry.py", line 315, in increment total -= 1 TypeError: unsupported operand type(s) for -=: "Retry" and "int"
当然尝试pip3亦是如此
解决过程First
菜鸟给的安装方法很直接的安装方法, 失败
Second
老方法从Python Extension Packages 下载whl 文件, 要么直接通过树莓派的网络下载, 要么通过你的电脑下载, 通过U盘拷贝到树莓派, 再安装, 当然未果, 而且报错略有不同
pi@raspberrypi:~/Desktop $ pip install --upgrade pip Collecting pip Exception: Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepa re_files ignore_dependencies=self.ignore_dependencies)) File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prep are_file require_hashes File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in p opulate_link self.link = finder.find_requirement(self, upgrade) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requir ement all_candidates = self.find_all_candidates(req.name) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, in find_all_ca ndidates for page in self._get_pages(url_locations, project_name): File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_pages page = self._get_page(location) File "/usr/lib/python2.7/dist-packages/pip/index.py", line 683, in _get_page return 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/s essions.py", line 501, in get return self.request("GET", url, **kwargs) File "/usr/lib/python2.7/dist-packages/pip/download.py", line 386, in request return super(PipSession, self).request(method, url, *args, **kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 488, in request resp = self.send(prep, **send_kwargs) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 630, in send history = [resp for resp in gen] if allow_redirects else [] File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 190, in resolve_redirects **adapter_kwargs File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/s essions.py", line 609, in send r = adapter.send(request, **kwargs) File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachec ontrol/adapter.py", line 47, in send resp = super(CacheControlAdapter, self).send(request, **kw) File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/a dapters.py", line 423, in send timeout=timeout File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/con nectionpool.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/uti l/retry.py", line 315, in increment total -= 1 TypeError: unsupported operand type(s) for -=: "Retry" and "int"
Third
使用 sudo apt-get install python-pip
pi@raspberrypi:~ $ sudo apt-get install python3-pip 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 python3-pip 已经是最新版 (9.0.1-2+rpt2)。 升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 98 个软件包未被升 级。
没报错, 但依然无法安装
fourth
使用 sudo python -m pip install --upgrade --force pip
再次sudo pip安装,无果
last
感谢大神的分享
我才发觉这是一个新手的通用问题:
树莓派自带的Linux系统附带了一个来自前寒武纪的pip版本, 如果您不想花费数小时来调试与pip相关的问题, 那么就必须升级它。
甚至是Ubuntu系统亦是如此
使用如下代码:
apt-get remove python-pip python3-pip wget https://bootstrap.pypa.io/get-pip.py python get-pip.py python3 get-pip.py
可能有小问题, 别忘了sudo
pi@raspberrypi:~/Desktop $ python get-pip.py Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting pip Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(": Failed to establish a new connec tion: [Errno -3] xe5x9fx9fxe5x90x8dxe8xa7xa3xe6x9ex90xe6x9ax82xe 6x97xb6xe5xa4xb1xe8xb4xa5",)": /simple/pip/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connection: [Errno -3] xe5x9fx9fxe5x90x8dxe8xa7xa3xe6x9ex90xe6x9ax82xe6x97xb6xe5xa4xb1xe8xb4xa5",)": /simple/pip/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connection: [Errno -3] xe5x9fx9fxe5x90x8dxe8xa7xa3xe6x9ex90xe6x9ax82xe6x97xb6xe5xa4xb1xe8xb4xa5",)": /simple/pip/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connection: [Errno -3] xe5x9fx9fxe5x90x8dxe8xa7xa3xe6x9ex90xe6x9ax82xe6x97xb6xe5xa4xb1xe8xb4xa5",)": /simple/pip/ Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connection: [Errno -3] xe5x9fx9fxe5x90x8dxe8xa7xa3xe6x9ex90xe6x9ax82xe6x97xb6xe5xa4xb1xe8xb4xa5",)": /simple/pip/ Downloading https://www.piwheels.org/simple/pip/pip-18.0-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 336kB/s Installing collected packages: pip Could not install packages due to an EnvironmentError: [Errno 13] 权限不够: "/usr/local/lib/python2.7/dist-packages/pip" Consider using the `--user` option or check the permissions.
pi@raspberrypi:~/Desktop $ sudo python get-pip.py Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting pip Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 19kB/s Installing collected packages: pip Successfully installed pip-18.0
最后再通过之前的whl文件安装Django, 就OK了, 当然 sudo pip install django 亦可
pi@raspberrypi:~/Desktop $ sudo pip3 install Django-2.1.2-py3-none-any.whl Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Processing ./Django-2.1.2-py3-none-any.whl Collecting pytz (from Django==2.1.2) Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(": Failed to establish a new connec tion: [Errno -3] 域名解析暂时失败",)": /simple/pytz/ Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connec tion: [Errno -3] 域名解析暂时失败",)": /simple/pytz/ Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connec tion: [Errno -3] 域名解析暂时失败",)": /simple/pytz/ Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connec tion: [Errno -3] 域名解析暂时失败",)": /simple/pytz/ Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by "NewConnectionError(" : Failed to establish a new connec tion: [Errno -3] 域名解析暂时失败",)": /packages/30/4e/27c34b62430286c6d59177a08 42ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d591 77a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB ) 100% |████████████████████████████████| 512kB 33kB/s Installing collected packages: pytz, Django Successfully installed Django-2.1.2 pytz-2018.5
大功告成!如果之后我在搭建服务器时遇到问题, 我依旧会分享, 同志们晚安!
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/42566.html
摘要:工具树莓派温湿度传感器在开始实验之前,要在电脑上安装,并且建立好一个数据库连接。到这里对电脑配置就结束了,对了,还有如果你们到时运行树莓派代码出现远程连接失败错误码,像下图这是因为,你的防火墙开了,把防火墙关掉就不会报这个错误了。 ...
摘要:因为树莓派是架构的,所以的安装和使用也都有不同。反过来别的上的镜像,也不能在树莓派上运行。有一个叫的仓库制作了非常多树莓派专用,可以参考下。树莓派参考参考树莓派安装,最难的在于正确的选择源和添加,才能找到版本适合的并下载。 因为树莓派是ARM架构的,所以Docker的安装和使用也都有不同。需要讲的内容比较多,这里单挑出来。 树莓派是基于ARM架构的,和PC不同。所以即使树莓派上能做一些...
阅读 3321·2021-11-10 11:36
阅读 3207·2021-10-08 10:21
阅读 2819·2021-09-29 09:35
阅读 2365·2021-09-22 16:06
阅读 3894·2021-09-09 09:33
阅读 1286·2019-08-30 15:44
阅读 3144·2019-08-30 10:59
阅读 2958·2019-08-29 15:32