本文介绍: 作为刚接触python来说,装那些库总是费了不少的劲,比如pip install XXX 总是出错,其实是网速的问题,只要使用python –m pip install —upgrade pip 这个命令就可以了
首先,欢迎你能点进这篇博客!(如果你想直接看解决方法的话,请直接看5;如果你想知道为什么报错+解决方法的话,请看4、5;如果你不嫌弃我废话的话,就全看了叭!)
- 本人完全是python小菜鸡,要不是因为这学期开了数据分析和python的课,我是完全没有自觉性去学习python的
- 这不,因为基本不咋懂python库啥的,所以一开始被虐的很惨,也是上网找了很多才解决,真的很闹心!
- 言归正传,因为我遇到了这样的问题:就是我第一次想使用 pip install 命令的时候,总是报错,比如pip install ipython吧(其他应该也是一样的)
Exception: Traceback (most recent call last): File "D:python3.7libsite-packagespip_vendorurllib3response.py", line 302, in _error_catcher yield File "D:python3.7libsite-packagespip_vendorurllib3response.py", line 384, in read data = self._fp.read(amt) File "D:python3.7libsite-packagespip_vendorcachecontrolfilewrapper.py", line 60, in read data = self.__fp.read(amt) File "D:python3.7libhttpclient.py", line 447, in read n = self.readinto(b) File "D:python3.7libhttpclient.py", line 491, in readinto n = self.fp.readinto(b) File "D:python3.7libsocket.py", line 589, in readinto return self._sock.recv_into(b) File "D:python3.7libssl.py", line 1049, in recv_into return self.read(nbytes, buffer) File "D:python3.7libssl.py", line 908, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:python3.7libsite-packagespip_internalbasecommand.py", line 228, in main status = self.run(options, args) File "D:python3.7libsite-packagespip_internalcommandsinstall.py", line 291, in run resolver.resolve(requirement_set) File "D:python3.7libsite-packagespip_internalresolve.py", line 103, in resolve self._resolve_one(requirement_set, req) File "D:python3.7libsite-packagespip_internalresolve.py", line 257, in _resolve_one abstract_dist = self._get_abstract_dist_for(req_to_install) File "D:python3.7libsite-packagespip_internalresolve.py", line 210, in _get_abstract_dist_for self.require_hashes File "D:python3.7libsite-packagespip_internaloperationsprepare.py", line 310, in prepare_linked_requirement progress_bar=self.progress_bar File "D:python3.7libsite-packagespip_internaldownload.py", line 837, in unpack_url progress_bar=progress_bar File "D:python3.7libsite-packagespip_internaldownload.py", line 674, in unpack_http_url progress_bar) File "D:python3.7libsite-packagespip_internaldownload.py", line 898, in _download_http_url _download_url(resp, link, content_file, hashes, progress_bar) File "D:python3.7libsite-packagespip_internaldownload.py", line 618, in _download_url hashes.check_against_chunks(downloaded_chunks) File "D:python3.7libsite-packagespip_internalutilshashes.py", line 48, in check_against_chunks for chunk in chunks: File "D:python3.7libsite-packagespip_internaldownload.py", line 586, in written_chunks for chunk in chunks: File "D:python3.7libsite-packagespip_internalutilsui.py", line 159, in iter for x in it: File "D:python3.7libsite-packagespip_internaldownload.py", line 575, in resp_read decode_content=False): File "D:python3.7libsite-packagespip_vendorurllib3response.py", line 436, in stream data = self.read(amt=amt, decode_content=decode_content) File "D:python3.7libsite-packagespip_vendorurllib3response.py", line 401, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "D:python3.7libcontextlib.py", line 130, in __exit__ self.gen.throw(type, value, traceback) File "D:python3.7libsite-packagespip_vendorurllib3response.py", line 307, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. You are using pip version 10.0.1, however version 22.0.4 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
试了很多方法都不成功,就算使用它给出的提示(如下代码块中所示),也没什么luan用,还是报上面那样的错,就很让人窝火!
python -m pip install --upgrade pip
- 所以这是为什么呢?跟python,pip啥的都没关系,其实主要原因是网速不好。因为python的服务器是在国外,而在国内要连接国外的的服务器肯定很慢(你从官网download的时候就应该感觉的到了),这时候的解决办法肯定就是就近原则了喽,那就选择国内的服务器。国内的服务器,如下图所示(我看尚硅谷的视频才知道的,下图也是从视频里截的,如果你们想看,链接在这儿),比如阿里云、中国科技大学等等
- 芜湖,直接解决办法! 比如我还是下载ipython这个包(这个包比较小,你可以作为测试之用,先下来看看能不能Successfully,之后再尝试下其他比较大的包;这里我使用上图豆瓣那个,就是说比较好记)
pip install ipython -i https://pypi.douban.com/simple/
原文地址:https://blog.csdn.net/ywxjy/article/details/123488709
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_20552.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。