Memory Error on pip install (SOLVED)

Memory Error when using pip install on Python can emerge both from command line or from a IDE like PyCharm, usually when the package size is big.

When you try to install a python package with pip install packagename but it fails due to a Memory Error, you can fix it in this way:

  1. Go to your console
  2. Optional: if your application is into a a virtual environment activate it
  3. pip install packagename --no-cache-dir

The package will now be downloaded with the cache disabled (see pip –help).

Thanks to David Wolever

7 responses to “Memory Error on pip install (SOLVED)”

  1. Thanks for posting that — I kept getting a memory error while trying python -m pip install kivy.deps.gstreamer and it was quite frustrating, but adding the –no-cache-dir fixed it.

    1. At the time I was using Kivy and I was stuck by this error too. Thank you for commenting and happy python coding!

  2. The described solution does work and might be the right thing to do in some cases. For my case I simply needed to bump up the RAM on my VM and the MemoryError was gone and it was probably the better solution (for my case).

    1. Thank you for posting this alternative solution. Definetely to try if you run PyCharm on a guest OS!

  3. I had a challenging MemoryError exception while trying to install PySpark on a Virtual Hosted Ubuntu machine, but adding the –no -cache-dir option worked like a charm. Thanks

  4. Great blog I enjooyed reading

%d bloggers like this: