lxml will never finish building on ubuntu
I ran this on VM with 768MB ram (which i didn't notice was the value i set) and it took several hours and didn't finish.
Changing ram to 3GB made it finish in few minutes after restarting and trying again.
I ran into the same problem when trying to "pip install" a package that depends on lxml on a Raspberry Pi 1 B+. After several hours (and several attempts), the SSH connection dropped without finishing the wheel build. It seems like an out-of-memory situation.
I opted on installing the pre-built binary packages using apt install python-lxml
or apt install python3-lxml
respectively.
The newest version of pip, unnecessarily spends excessive amount of time to build wheels and resolve dependency issues while building a package with requirements.txt or a setuptools/distutils setup.py
A quick fix is to revert to a version of pip prior to 21.0 (ideally in a virtual environment), where the legacy resolver is still supported, according to this discussion: sunsetting legacy resolver
As of July 28th, 2021 pip v21.2.1 still seems to have the legacy resolver support.
pip install pip==20.2.4
Command below uses an earlier version of dependency resolver to install lxml.
pip install --use-deprecated=legacy-resolver lxml
Saved me a lot of time and hassle.
Note that if you run top
in a separate terminal you'll notice that your system is busy building the lxml
package:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1645 root 20 0 322224 305740 5384 R 100.0 29.8 3:27.47 /usr/lib/gcc/arm-linux-gnueabihf/5/cc1 -quiet -I /usr/include/libxml2 -I src/lxml/includes -I /usr/include/python2.7 -imultiarch arm-linux-gnueabihf -D_REENTRANT -D ...
If you're building on a VM or SBC with limited resources this can take a while...