If you are getting an unexpected MemoryError and you think you should have plenty of RAM available, Then it might happen because you are using a 32-bit python installation.
The easier solution would be, if you have a 64-bit operating system, is to switch to a 64-bit installation of python.
But, the issue is that 32-bit python only has access to ~4GB of RAM. This can shrink even further if your operating system is 32-bit, because of the operating system overhead.
For more information about 32-bit operating systems, ~4GB of RAM you can refer here: https://superuser.com/questions/372881/is-there-a-technical-reason-why-32-bit-windows-is-limited-to-4gb-of-ram