title: aws ec2 error installing matplotlib
body: <p>I am trying to run a script on an ec2 instance which requires <strong>matplotlib</strong> and apparently it is not installed by default. So I am trying to do it</p>
  
  <pre><code>pip install -U matplotlib
  </code></pre>
  
  <p>as you can see in the image, I get this error:
  <a href="https://i.stack.imgur.com/OdoqD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OdoqD.png" alt="enter image description here"></a></p>
  
  <p>and here is the text version:</p>
  
  <pre><code>Collecting matplotlib   Downloading matplotlib-2.0.0.tar.gz (53.2MB)
      99% |████████████████████████████████| 53.2MB 24.0MB/s eta 0:00:01  Exception:   Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 246, in main
        status = self.run(options, args)
      File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 342, in run
        requirement_set.prepare_files(finder)
      File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 345, in prepare_files
        functools.partial(self._prepare_file, finder))
      File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 290, in _walk_req_to_install
        more_reqs = handler(req_to_install)
      File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 487, in _prepare_file
        download_dir, do_download, session=self.session,
      File "/usr/lib/python2.7/dist-packages/pip/download.py", line 827, in unpack_url
        session,
      File "/usr/lib/python2.7/dist-packages/pip/download.py", line 673, in unpack_http_url
        from_path, content_type = _download_http_url(link, session, temp_dir)
      File "/usr/lib/python2.7/dist-packages/pip/download.py", line 888, in _download_http_url
        _download_url(resp, link, content_file)
      File "/usr/lib/python2.7/dist-packages/pip/download.py", line 621, in _download_url
        for chunk in progress_indicator(resp_read(4096), 4096):
      File "/usr/lib/python2.7/dist-packages/pip/utils/ui.py", line 133, in iter
        for x in it:
      File "/usr/lib/python2.7/dist-packages/pip/download.py", line 586, in resp_read
        decode_content=False):
      File "/usr/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 273, in stream
        data = self.read(amt=amt, decode_content=decode_content)
      File "/usr/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/response.py", line 203, in read
        data = self._fp.read(amt)
      File "/usr/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/filewrapper.py", line 54, in read
        self.__callback(self.__buf.getvalue())
      File "/usr/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/controller.py", line 224, in cache_response
        self.serializer.dumps(request, response, body=body),
      File "/usr/lib/python2.7/dist-packages/pip/_vendor/cachecontrol/serialize.py", line 81, in dumps
        ).encode("utf8"),   MemoryError
  </code></pre>