4

I referred to this article, but used more recent libraries. To be explicit, I downloaded libgpg-error-1.10, libgcrypt-1.5.0,gnutls-3.1.3 and libvirt-1.0.0

libgpg-error-1.10, libgcrypt-1.5.0 installed OK and when configure gnutls-3.1.3, an error comes:

configure: error:

* Libnettle 2.5 was not found. Note that you must compile nettle with gmp support.

What I want is to use libvirt's python binding(i.e. import libvirt in python). Could anyone explain how to get a useable python libvirt library?

can.
  • 2,098
  • 8
  • 29
  • 42

4 Answers4

11

Your easiest options is probably using homebrew to install libvirt:

$ brew install libvirt

After that compiling the Python bindings for libvirt should be trivial.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Pedro Romano
  • 10,973
  • 4
  • 46
  • 50
  • 2
    libvirt python bindings are compiled automatically, but need to be linked under `/Library/Python/2.7/site-packages/` from `/usr/local/Cellar/libvirt/0.9.11.6/lib/python2.7/site-packages/` manually – can. Oct 31 '12 at 07:44
7

After you install libvirt with:

$ brew install libvirt

you can install the libvirt python bindings with pip:

$ pip install libvirt-python

Flannon
  • 101
  • 1
  • 5
0

I ran the following commands on a fairly fresh MacOSX 10.10.5

bash-3.2$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
bash-3.2$ brew install libvirt
bash-3.2$ brew install libvirt-python
bash-3.2$ pip install libvirt-python
bash-3.2$ echo Instructions at http://stackoverflow.com/questions/13136884/how-to-build-and-install-libvirt-on-mac do not work.

bash-3.2$ sudo easy_install pip
bash-3.2$ pip install libvirt-python
bash-3.2$ echo typical python stuff up - when the install of a tool gets in your way - toss the tool
bash-3.2$ echo unless the tool has worked many many times before.
bash-3.2$ pip install pkg-config
bash-3.2$ brew install pkg-config
bash-3.2$ pip install libvirt-python
bash-3.2$ sudo pip install libvirt-python
bash-3.2$ 
Andrew
  • 7,286
  • 3
  • 28
  • 38
0

Andrews solution works with one modification for El Capitan and up. As theses versions do not allow write access to /usr/share you need to provide pkg-config with the path of the libvirt api, something like:

export PKG_CONFIG_PATH=/usr/local/Cellar/libvirt/4.3.0/lib/pkgconfig
Ivan Vinogradov
  • 4,269
  • 6
  • 29
  • 39