I probably had the same problem on my rpi3.
The output said virtual memory exhausted: Cannot allocate memory
So I increased the swapfile size as described here: https://www.bitpi.co/2015/02/11/how-to-change-raspberry-pis-swapfile-size-on-rasbian/ and the installation worked as expected.