摘要:沒報錯但依然無法安裝使用再次安裝無果感謝大神的分享我才發覺這是一個新手的通用問題樹莓派自帶的系統附帶了一個來自前寒武紀的版本,如果您不想花費數小時來調試與相關的問題,那么就必須升級它。
諸位, 不好意思哈, 請允許我把完整的標題寫完(標題不能超過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
大功告成!如果之后我在搭建服務器時遇到問題, 我依舊會分享, 同志們晚安!
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/42566.html
摘要:工具樹莓派溫濕度傳感器在開始實驗之前,要在電腦上安裝,并且建立好一個數據庫連接。到這里對電腦配置就結束了,對了,還有如果你們到時運行樹莓派代碼出現遠程連接失敗錯誤碼,像下圖這是因為,你的防火墻開了,把防火墻關掉就不會報這個錯誤了。 ...
摘要:因為樹莓派是架構的,所以的安裝和使用也都有不同。反過來別的上的鏡像,也不能在樹莓派上運行。有一個叫的倉庫制作了非常多樹莓派專用,可以參考下。樹莓派參考參考樹莓派安裝,最難的在于正確的選擇源和添加,才能找到版本適合的并下載。 因為樹莓派是ARM架構的,所以Docker的安裝和使用也都有不同。需要講的內容比較多,這里單挑出來。 樹莓派是基于ARM架構的,和PC不同。所以即使樹莓派上能做一些...
閱讀 3344·2021-11-10 11:36
閱讀 3244·2021-10-08 10:21
閱讀 2841·2021-09-29 09:35
閱讀 2416·2021-09-22 16:06
閱讀 3959·2021-09-09 09:33
閱讀 1327·2019-08-30 15:44
閱讀 3171·2019-08-30 10:59
閱讀 2982·2019-08-29 15:32