'错误:解压缩数据时出错-5:不完整或截断的流'安装pip包时

时间:2015-08-07 13:03:06

标签: python pip

我在virtualenv中运行pip install Pillow==2.9.0时出现以下错误:error: Error -5 while decompressing data: incomplete or truncated stream

其他软件包安装/卸载很好,它似乎只影响Pillow 2.9.0。我似乎并不重要(或不是)。

下载源tarball并从中进行安装,但由于这是在构建服务器上,因为我想依赖pip install -r requirements.txt

而不是理想的解决方法

版本:

  • pip --versionpip 7.1.0 from /usr/local/lib/python2.7/site-packages (python 2.7)
  • python --versionPython 2.7.10

完整的追溯是:

Collecting Pillow==2.9.0
/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Exception:
Traceback (most recent call last):
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/commands/install.py", line 282, in run
    requirement_set.prepare_files(finder)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/req/req_set.py", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/req/req_set.py", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/req/req_set.py", line 491, in _prepare_file
    session=self.session)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 825, in unpack_url
    session,
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 673, in unpack_http_url
    from_path, content_type = _download_http_url(link, session, temp_dir)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 857, in _download_http_url
    stream=True,
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/download.py", line 373, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 36, in send
    cached_response = self.controller.cached_request(request)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/controller.py", line 102, in cached_request
    resp = self.serializer.loads(request, self.cache.get(cache_url))
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/serialize.py", line 108, in loads
    return getattr(self, "_loads_v{0}".format(ver))(request, data)
  File "/mnt/jenkins/jobA/workspace/.pyenv/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/serialize.py", line 164, in _loads_v2
    cached = json.loads(zlib.decompress(data).decode("utf8"))
error: Error -5 while decompressing data: incomplete or truncated stream

3 个答案:

答案 0 :(得分:27)

原来在pip的本地缓存中存在损坏的条目(位于我的情况下,默认情况下我相信,在~/.cache/pip中)。

我通过尝试pip install --no-cache-dir Pillow==2.9.0测试了这一点,看哪,它有效。

为了确认它是缓存,我跑了:

pip uninstall Pillow
rm -rf ~/.cache/pip/*`
pip install Pillow==2.9.0

之前失败的地方取得了成功。

我不知道缓存有什么问题,但我的猜测是pip在下载过程中被中断导致Pillow的缓存数据被破坏

答案 1 :(得分:0)

我发现我的问题与磁盘的内存有关。

运行df显示我使用了92%的内存。删除并清理硬盘驱动器后(使用Disk Usage Analyzer),我能够成功解压缩数据

答案 2 :(得分:0)

适用于与我的情况相似的任何人。安装期间空间不足->缓存仍然存在,但已损坏。 那么呢? 删除此文件夹~/.cache/pip,然后pip再次起作用。