使用pip安装Matplotlib时出现内存错误 [英] Memory error while using pip install Matplotlib
问题描述
我正在使用Python 2.7,如果我尝试安装Matplotlib,如果我使用"pip install matplotlib",则会收到此错误
I am using Python 2.7, If i try to install Matplotlib I am getting this error if i use "pip install matplotlib"
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"
可能是什么问题? 我正在将树莓派2与16gb SD卡一起使用.我仍然有8gb的可用数据,但仍然收到此错误. 请帮助
What might the problem be? I am using raspberry Pi 2 with a 16gb SD card. I still have 8gb data free but still getting this error. Kindly help
推荐答案
出现此错误是因为,似乎pip的缓存机制正在尝试在将整个文件缓存到内存之前将其读取到内存中……这在一定程度上造成了问题内存环境,因为matplotlib约为50mb.
This error is coming up because, it seems, pip's caching mechanism is trying to read the entire file into memory before caching it… which poses a problem in a limited-memory environment, as matplotlib is ~50mb.
在修补pip以使用恒定空间缓存算法之前,一种更简单的解决方案是将pip
与--no-cache-dir
一起运行以避免缓存:
A simpler solution, until pip is patched to use a constant-space caching algorithm, is to run pip
with --no-cache-dir
to avoid the cache:
$ pip --no-cache-dir install matplotlib
这篇关于使用pip安装Matplotlib时出现内存错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!