1. 程式人生 > >pip升級出錯解決方法ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read ti med out.

pip升級出錯解決方法ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read ti med out.

pip升級出錯:
C:\Users\test>python -m pip install -U pip
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    15% |¨€¨€¨€¨€¨€                           | 194kB 5.6kB/s eta 0:03:12Ex
ception:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\basecommand.py", l
ine 215, in main
    status = self.run(options, args)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\commands\install.p
y", line 299, in run
    requirement_set.prepare_files(finder)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\req\req_set.py", l
ine 370, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\req\req_set.py", l
ine 587, in _prepare_file
    session=self.session, hashes=hashes)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line
 810, in unpack_url
    hashes=hashes
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line
 649, in unpack_http_url
    hashes)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line
 871, in _download_http_url
    _download_url(resp, link, content_file, hashes)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line
 595, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\utils\hashes.py",
line 46, in check_against_chunks
    for chunk in chunks:
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line
 563, in written_chunks
    for chunk in chunks:
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\utils\ui.py", line
 139, in iter
    for x in it:
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\download.py", line
 552, in resp_read
    decode_content=False):
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\p
ackages\urllib3\response.py", line 353, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\p
ackages\urllib3\response.py", line 320, in read
    flush_decoder = True
  File "C:\Python27\lib\contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python27\lib\site-packages\pip-8.1.2-py2.7.egg\pip\_vendor\requests\p
ackages\urllib3\response.py", line 242, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read ti
med out.
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.


解決辦法:


1、在Python的安裝目錄C:/Python27/Lib/裡找到mimetypes.py檔案;2、開啟mimetypes.py檔案,在import結束後新增以下程式碼:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')