0

I am trying to install mathplotlib on my Raspberry Pi using

python -m pip install matplotlib

My environment is ISO-8859-1, not UTF-8 as default.

[14:08]pi@ras3:/tmp$ locale
LANG=de_DE
LANGUAGE=de_DE
LC_CTYPE="de_DE"
LC_NUMERIC="de_DE"
LC_TIME="de_DE"
LC_COLLATE="de_DE"
LC_MONETARY="de_DE"
LC_MESSAGES="de_DE"
LC_PAPER="de_DE"
LC_NAME="de_DE"
LC_ADDRESS="de_DE"
LC_TELEPHONE="de_DE"
LC_MEASUREMENT="de_DE"
LC_IDENTIFICATION="de_DE"
LC_ALL=de_DE

When I run PIP, I get following error:

[14:10]root@ras3:/tmp$ python -m pip install matplotlib
Collecting matplotlib
  Downloading https://files.pythonhosted.org/packages/1e/20/2032ad99f0dfe0f60970941af36e8d0942d3713f442bb3df37ac35d67358/matplotlib-2.2.4.tar.gz (37.0MB)
    99% |############################### | 37.0MB 1.5MB/s eta 0:00:01Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 620, in _prepare_file
    session=self.session, hashes=hashes)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 821, in unpack_url
    hashes=hashes
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 659, in unpack_http_url
    hashes)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 882, in _download_http_url
    _download_url(resp, link, content_file, hashes)
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 603, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/usr/lib/python2.7/dist-packages/pip/utils/hashes.py", line 46, in check_against_chunks
    for chunk in chunks:
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 571, in written_chunks
    for chunk in chunks:
  File "/usr/lib/python2.7/dist-packages/pip/utils/ui.py", line 139, in iter
    for x in it:
  File "/usr/lib/python2.7/dist-packages/pip/download.py", line 560, in resp_read
    decode_content=False):
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py", line 432, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/response.py", line 380, in read
    data = self._fp.read(amt)
  File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 63, in read
    self._close()
  File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 50, in _close
    self.__callback(self.__buf.getvalue())
  File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/controller.py", line 275, in cache_response
    self.serializer.dumps(request, response, body=body),
  File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py", line 55, in dumps
    "body": _b64_encode_bytes(body),
  File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/serialize.py", line 12, in _b64_encode_bytes
    return base64.b64encode(b).decode("ascii")
MemoryError

My first idea was that it could have to do with my ISO-8859-1 locale, as the mathplotlib might only be installable in an UTF-8 environment. So I set my LC_ALL to de_DE.UTF-8 before running PIP, but I get just the same error.

What can I do? Is there a different way of installing/using mathplotlib or an alternative library for printing 3d plots?

oxr463
  • 1,573
  • 3
  • 14
  • 34
Daniel Marschall
  • 3,739
  • 2
  • 28
  • 67
  • Does it work if you explicitly select a version of matplotlib to install, e.g. `python -m pip install matplotlib==1.5.3`? And what about using Python 3, e.g. `python3 -m pip install matplotlib`? – jmd_dk Jun 26 '19 at 12:16
  • 4
    Possible duplicate of [Memory error while using pip install Matplotlib](https://stackoverflow.com/questions/29466663/memory-error-while-using-pip-install-matplotlib) – jmd_dk Jun 26 '19 at 12:19
  • The cache-dir argument did not work for me. I am not sure if it is a low-memory problem as I have approx 550 MB free RAM. Swap is turned off though (to avoid too much write access to the SD card). But changing "python" to "python3" works! I could now install mathplotlib and use it inside the Thonny IDE. Thank you very much for this hint! – Daniel Marschall Jun 26 '19 at 12:28
  • You're welcome. If you specifically need Python 2, try updating pip first: `python -m pip install --upgrade pip`. – jmd_dk Jun 26 '19 at 12:31
  • `pip --no-cache-dir install matplotlib` – dubbbdan Jun 26 '19 at 13:46

0 Answers0