Help us understand the problem. What is going on with this article?

【備忘録】pipでライブラリインストール時にmemory errorが出たときの対処法

More than 1 year has passed since last update.

※本エントリは完全に個人の備忘録です。

Raspberry Piで環境構築時に
pythonのライブラリmatplotlabをpipでインストールしようとしたときに下記エラーが出てきた。

Exception:
  Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 232, in main
      status = self.run(options, args)
    File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 339, in run
      requirement_set.prepare_files(finder)
    File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 355, in prepare_files
      do_download, session=self.session,
    File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 782, in unpack_url
      session,
    File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 667, in unpack_http_url
      from_path, content_type = _download_http_url(link, session, temp_dir)
    File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 843, in _download_http_url
      _download_url(resp, link, content_file)
    File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 615, in _download_url
      for chunk in progress_indicator(resp_read(4096), 4096):
    File "/usr/local/lib/python2.7/dist-packages/pip/utils/ui.py", line 46, in iter
      for x in it:
    File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 580, in resp_read
      decode_content=False):
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 256, in stream
      data = self.read(amt=amt, decode_content=decode_content)
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 186, in read
      data = self._fp.read(amt)
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/filewrapper.py", line 54, in read
      self.__callback(self.__buf.getvalue())
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/controller.py", line 205, in cache_response
      self.serializer.dumps(request, response, body=body),
    File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/serialize.py", line 81, in dumps
      ).encode("utf8"),
  MemoryError"

なんだこれ?と思い、「pip MemoryError」で検索したらStack Overflowで数多くの投稿が。
どうやら下記オプションを追加すれば良いとのこと。

$ pip --no-cache-dir install matplotlib

--no-cache-dir はキャッシュを無効化して実行するオプションらしい。
MemoryErrorを引き起こしたのは、インストール開始時に前回キャッシュが残っていたのが原因なのかしら・・・

試しに上記コマンドで再度インストールしてみたら、無事完了しました。よかったよかった。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away