Memory error when using pip install Matplotlib

I use Python 2.7 if I try to install Matplotlib, I get 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" 

What could be the problem? I am using raspberry Pi 2 with a 16 gigabyte SD card. I still have 8 GB of data, but still getting this error. Request for help

+45
python matplotlib
Apr 06 '15 at 6:47
source share
2 answers

This error occurs because it seems that the pip caching mechanism is trying to read the entire file in memory before it is cached ... which creates a problem in a limited memory environment, because matplotlib ~ 50mb.

A simpler solution, until pip is fixed to use the caching algorithm with constant space, you need to run pip with --no-cache-dir to avoid the cache:

 $ pip --no-cache-dir install matplotlib 
+143
Jul 20 '15 at 20:46
source share

It seems you don't have enough memory to create matplotlib from scratch. To overcome this, enable swap:

 # create swap file of 512 MB dd if=/dev/zero of=/swapfile bs=1024 count=524288 # modify permissions chown root:root /swapfile chmod 0600 /swapfile # setup swap area mkswap /swapfile # turn swap on swapon /swapfile 

Or, if you have raspbian installed on your SD card, you can install matplotlib from the repository:

 apt-get install python-matplotlib 
+17
Apr 6 '15 at 7:36
source share



All Articles