Compiling error installing lxml on ubuntu

A compiler error was observed during installing lxml on ubuntu the error looks something like: error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 4, and it’s most likely caused by low memory.


  • Enlarge memory if possible, for example, if the issue was encountered on a virtual machine

  • If enlarging memory is not possible, then add swap file:

    sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile

See reference.

ubuntu python