1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pipでエラー"zlib.error: Error -5 while decompressing data..."の対処法

Last updated at Posted at 2018-06-13

解決したいこと

以下のような「zlib.error: Error -5 while decompressing data: incomplete or truncated stream」エラーが出たときの対処です。

OSはUbuntu 16.04です。

ib/python3.5/dist-packages/pipenv/patched/piptools/repositories/pypi.py", line 372, in open_local_or_remote_file
    response = session.get(url, headers=headers, stream=True)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/_vendor/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/_vendor/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/_vendor/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/_vendor/cachecontrol/adapter.py", line 37, in send
    cached_response = self.controller.cached_request(request)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/_vendor/cachecontrol/controller.py", line 111, in cached_request
    resp = self.serializer.loads(request, cache_data)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/_vendor/cachecontrol/serialize.py", line 114, in loads
    return getattr(self, "_loads_v{0}".format(ver))(request, data)
  File "/usr/local/lib/python3.5/dist-packages/pipenv/vendor/pip9/_vendor/cachecontrol/serialize.py", line 176, in _loads_v2
    cached = json.loads(zlib.decompress(data).decode("utf8"))
zlib.error: Error -5 while decompressing data: incomplete or truncated stream

 pipenv installしたときに起こりました。

解決方法

以下のコマンドで.cache/pip/内のファイルを削除しました。
(実際は削除は怖いのでmvで違う名前変えました)

rm -rf ~/.cache/pip/*`

このエラーの原因だと思われること

pipenv install OOOをしたときに“(No space left on device”でpipが強制終了したのが、影響しているのではないかなと思ってます。そのため、想定外な状態でpipが終了して、キャッシュが悪さをしてこのエラーが起こっていたのだと思います。

このエラーpipenvに限った問題ではなくpipに関することだ思います。参考のリンクでもpip install XXXでこのエラーが起こっていたようです。

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?