Mathematics, philosophy, code, travel and everything in between. More about me…

I write about

How to deal with a compiler crash when building pandas

When installing the Python package pandas on a small server you might encounter a cryptic gcc error in the middle of the compilation: internal compiler error: Killed (program cc1). Most likely this is a memory problem and can be fixed easily.

The error message looks like this:

x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4

According to this thread this happens because the build is rather memory hungry. In my experience it consumes 500+ MB of memory.

A simple workaround is to create a swapfile that will boost your virtual memory size even on a tiny server. This is how you create and activate a 1GB swap on Linux (run as root):

dd if=/dev/zero of=/swap1 bs=1M count=1024
mkswap /swap1
chown root:root /swap1
chmod 0600 /swap1
swapon /swap1
October 1, MMXIV — Python, Linux.