使用pip时“SSLError:读取操作超时”

时间:2013-09-23 11:50:28

标签: python pip

每当我尝试使用pip安装内容时,都会收到以下错误:

Downloading/unpacking Django>=1.5.1,<1.6 (from -r requirements.txt (line 1))
  Downloading Django-1.5.4.tar.gz (8.1MB): 8.0MB downloaded
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/vagrant/venv/local/lib/python2.7/site-packages/pip/basecommand.py", line 134, in main
    status = self.run(options, args)
  File "/vagrant/venv/local/lib/python2.7/site-packages/pip/commands/install.py", line 236, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/vagrant/venv/local/lib/python2.7/site-packages/pip/req.py", line 1092, in prepare_files
    self.unpack_url(url, location, self.is_download)
  File "/vagrant/venv/local/lib/python2.7/site-packages/pip/req.py", line 1238, in unpack_url
    retval = unpack_http_url(link, location, self.download_cache, self.download_dir)
  File "/vagrant/venv/local/lib/python2.7/site-packages/pip/download.py", line 622, in unpack_http_url
    download_hash = _download_url(resp, link, temp_location)
  File "/vagrant/venv/local/lib/python2.7/site-packages/pip/download.py", line 495, in _download_url
    chunk = resp.read(4096)
  File "/usr/lib/python2.7/socket.py", line 380, in read
    data = self._sock.recv(left)
  File "/usr/lib/python2.7/httplib.py", line 561, in read
    s = self.fp.read(amt)
  File "/usr/lib/python2.7/socket.py", line 380, in read
    data = self._sock.recv(left)
  File "/usr/lib/python2.7/ssl.py", line 241, in recv
    return self.read(buflen)
  File "/usr/lib/python2.7/ssl.py", line 160, in read
    return self._sslobj.read(len)
SSLError: The read operation timed out

Storing complete log in /home/vagrant/.pip/pip.log

这曾经不时发生在我身上,但现在我无法安装任何东西。我尝试添加--timeout=600,但它在相同的时间内失败(达到8.0M后几秒钟) 关于如何解决这个问题的任何想法?

3 个答案:

答案 0 :(得分:29)

尝试(注意--default):

pip --default-timeout=100 install django

如果仍然无效,您可以手动下载django1.5.4和:

https://docs.djangoproject.com/en/dev/topics/install/#installing-an-official-release-manually

类似问题:

pip search django produces time out errorpip install django timeout on MacOSX Lion

答案 1 :(得分:8)

这通常是因为互联网连接不畅而发生的;安装过程中丢失互联网连接重做命令,它应该可以正常工作。

答案 2 :(得分:0)

使用sudo pip install解决了我的问题(在我的本地计算机上)。我知道这个问题已经过时了,但是对于将来遇到这个问题的其他人来说,这对我有用。 :)