[libvirt] Python-libvirt in a virtual environment.

Hi, Could you guide me to install libvirt in a virtual environment..? OR How python-libvirt could be used within a virtual environment after installing it, in the system. Regards Sijo

On 03/05/2014 05:34 AM, Sijo Jose wrote:
Hi, Could you guide me to install libvirt in a virtual environment..? OR How python-libvirt could be used within a virtual environment after installing it, in the system.
Same way as in a non-virtual system. For example, if your virtual environment is using Fedora, then 'yum install libvirt-client libvirt-python', then using it is as simple as: $ python
import libvirt conn = libvirt.open("...") ... use conn
where the URI you pass to libvirt.open is whatever needed to connect to the machine where your guests are running, such as "qemu://host/system". -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

@Michel using virtualenv we can create an isolated environment in the system. Just go through - http://docs.python-guide.org/en/latest/dev/virtualenvs/ @Eric I'm using Ubuntu, and I was able to install and use libvirt using sudo apt-get install python-libvirt but its not available in tg2 virtual environment. Moreover if you try to install in the virtualenv using the sudo apt-get install python-libvirt, it would say the package is been already installed. On Wed, Mar 5, 2014 at 6:51 PM, Eric Blake <eblake@redhat.com> wrote:
On 03/05/2014 05:34 AM, Sijo Jose wrote:
Hi, Could you guide me to install libvirt in a virtual environment..? OR How python-libvirt could be used within a virtual environment after installing it, in the system.
Same way as in a non-virtual system. For example, if your virtual environment is using Fedora, then 'yum install libvirt-client libvirt-python', then using it is as simple as:
$ python
import libvirt conn = libvirt.open("...") ... use conn
where the URI you pass to libvirt.open is whatever needed to connect to the machine where your guests are running, such as "qemu://host/system".
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Sijo Jose wrote:
@Michel using virtualenv we can create an isolated environment in the system. Just go through - http://docs.python-guide.org/en/latest/dev/virtualenvs/ @Eric I'm using Ubuntu, and I was able to install and use libvirt using sudo apt-get install python-libvirt but its not available in tg2 virtual environment.
Moreover if you try to install in the virtualenv using the sudo apt-get install python-libvirt, it would say the package is been already installed.
apt-get operates with system-level packages, so there's no difference if you run it from virtualenv or not. I think you have two options: - Install python-libvirt and create virtualenv with --system-site-packages [1] so it pulls system python-libvirt - Activate virtualenv and install python-libvirt using pip 1: http://virtualenv.readthedocs.org/en/latest/virtualenv.html#the-system-site-... Roman Bogorodskiy

I installed libvirt 1.2 tarball and then I use pip install libvirt-python inside virtual env.. it worked.. thanks -Sijo On Thu, Mar 6, 2014 at 12:02 PM, Roman Bogorodskiy <bogorodskiy@gmail.com>wrote:
Sijo Jose wrote:
@Michel using virtualenv we can create an isolated environment in the system. Just go through - http://docs.python-guide.org/en/latest/dev/virtualenvs/ @Eric I'm using Ubuntu, and I was able to install and use libvirt using sudo apt-get install python-libvirt but its not available in tg2 virtual environment.
Moreover if you try to install in the virtualenv using the sudo apt-get install python-libvirt, it would say the package is been already installed.
apt-get operates with system-level packages, so there's no difference if you run it from virtualenv or not.
I think you have two options:
- Install python-libvirt and create virtualenv with --system-site-packages [1] so it pulls system python-libvirt
- Activate virtualenv and install python-libvirt using pip
1: http://virtualenv.readthedocs.org/en/latest/virtualenv.html#the-system-site-...
Roman Bogorodskiy
participants (3)
-
Eric Blake
-
Roman Bogorodskiy
-
Sijo Jose