How to Install Lxml on Ubuntu

How to install lxml on Ubuntu

Since you're on Ubuntu, don't bother with those source packages. Just install those development packages using apt-get.

apt-get install libxml2-dev libxslt1-dev python-dev

If you're happy with a possibly older version of lxml altogether though, you could try

apt-get install python-lxml

and be done with it. :)

Problems installing lxml in Ubuntu

if you don't need a specific version from PyPI, you can always use the version packaged for Ubuntu.

$ sudo apt-get install python-lxml

... and then allow system site packages in your virtualenv.


update:

for clarification...
pip installs python packages from PyPI by default. However, many python packages are also packaged for Ubuntu and stored in the Ubuntu archives, You can install them via your system package manager (apt-get) instead of using pip. This can be helpful as the Ubuntu packages are compiled already, and will pull in any dependencies they need.

By default, virtualenv creates an isolated python enviornment, so you don't have access to system packages (that you installed using apt-get). However, you can allow system site packages in your virtualenv.

for example, let's install lxml from it's system package, create a virtualenv named "ENV" that allows access to system packages, and then import lxml to verify it works:

$ sudo apt-get install python-lxml
$ virtualenv --system-site-packages ENV
$ source ENV/bin/activate
(ENV)$ python -c "import xml"

How do I install lxml in linux without using aptitude or apt-get

You are running

pip3 install libxml2-dev

when you should be running

sudo apt-get install libxml2 libxml2-dev

(you may also need libxslt and its dev version as well)

pip doesn't install system libraries, apt and friends do that.

Installing lxml with pip in virtualenv Ubuntu 12.10 error: command 'gcc' failed with exit status 4

Here is the my saved note.

sudo apt-get install libxml2
sudo apt-get install libxslt1.1
sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev
sudo apt-get install python-libxml2
sudo apt-get install python-libxslt1
sudo apt-get install python-dev
sudo apt-get install python-setuptools

easy_install lxml

It has worked for my ubuntu 12.10

lxml will never finish building on ubuntu

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...

can't installing lxml on Ubuntu 12.04

Try this to get the deps:

apt-get build-dep python-lxml


Related Topics



Leave a reply



Submit