Memory error while using pip install Matplotlib

后端 未结 3 1670
自闭症患者
自闭症患者 2020-11-30 19:21

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 l         


        
相关标签:
3条回答
  • 2020-11-30 19:53

    It seems that you have insufficient RAM to build matplotlib from scratch. To overcome that, either turn on 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
    
    0 讨论(0)
  • 2020-11-30 20:03

    --no-cache-dir didn't work for me. I just closed all apps and only then I was able to finish installation.

    0 讨论(0)
  • 2020-11-30 20:06

    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.

    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
    
    0 讨论(0)
提交回复
热议问题