Python – Installation error via pip: command ‘x86_64-linux-gnu-gcc’ failed to install lxml in virtualenv

Installation error via pip: command ‘x86_64-linux-gnu-gcc’ failed to install lxml in virtualenv… here is a solution to the problem.

Installation error via pip: command ‘x86_64-linux-gnu-gcc’ failed to install lxml in virtualenv

When I activate virtualenv and type “pip install lxml”, the installation process crashes with the message:

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Solution

The error you should notice is the first “/usr/bin/ld: cannot find -lz”: tnhat indicates that you do not have zlib-dev installed. Depending on your Linux distribution, it can be named zlib-dev or zlib1g-dev in Ubuntu, I don’t know in other distributions.

Related Problems and Solutions