Skip to content

Excessive memory use when caching large packages #2984

Closed
@wolever

Description

@wolever

I'm getting a MemoryError while trying to install a large package (matplotlib) in a low memory (512mb) environment. It appears that the cause is the caching mechanism, as disabling the cache fixes the issue.

$ pip --version
pip 7.1.0 from /…/virtualenv/local/lib/python2.7/site-packages (python 2.7)
$ pip install matplotlib==1.4.3
Collecting matplotlib==1.4.3
  Downloading matplotlib-1.4.3.tar.gz (50.4MB)
    99% |████████████████████████████████| 50.4MB 20.5MB/s eta 0:00:01
Exception:
Traceback (most recent call last):
  File ".../pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File ".../pip/commands/install.py", line 282, in run
    requirement_set.prepare_files(finder)
  File ".../pip/req/req_set.py", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File ".../pip/req/req_set.py", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File ".../pip/req/req_set.py", line 491, in _prepare_file
    session=self.session)
  File ".../pip/download.py", line 825, in unpack_url
    session,
  File ".../pip/download.py", line 673, in unpack_http_url
    from_path, content_type = _download_http_url(link, session, temp_dir)
  File ".../pip/download.py", line 886, in _download_http_url
    _download_url(resp, link, content_file)
  File ".../pip/download.py", line 621, in _download_url
    for chunk in progress_indicator(resp_read(4096), 4096):
  File ".../pip/utils/ui.py", line 133, in iter
    for x in it:
  File ".../pip/download.py", line 586, in resp_read
    decode_content=False):
  File ".../pip/_vendor/requests/packages/urllib3/response.py", line 307, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File ".../pip/_vendor/requests/packages/urllib3/response.py", line 243, in read
    data = self._fp.read(amt)
  File ".../pip/_vendor/cachecontrol/filewrapper.py", line 54, in read
    self.__callback(self.__buf.getvalue())
  File ".../pip/_vendor/cachecontrol/controller.py", line 224, in cache_response
    self.serializer.dumps(request, response, body=body),
  File ".../pip/_vendor/cachecontrol/serialize.py", line 81, in dumps
    ).encode("utf8"),
MemoryError
$ pip install --no-cache-dir matplotlib==1.4.3
…
Successfully installed matplotlib-1.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions