skillfed

libvirt-python

The libvirt virtualization API python binding

libvirt-python v12.6.0 323.6K downloads/30d#7,604 on PyPI
Copyleft license LGPL-v2.0-or-later Active released

What it is and what it does

libvirt-python is a Python module that wraps the libvirt C library, exposing its virtualization management API to Python applications. It allows you to programmatically control virtual machines, containers, and other virtualization resources managed by libvirt on Linux and other operating systems. The bindings cover the main libvirt API as well as QEMU and LXC-specific extensions.

The package requires a working libvirt installation and development headers on your system, plus standard build tools (GCC, pkg-config) to compile. It supports Python 3.6 and later, is actively maintained, and carries no known security vulnerabilities. The LGPL-v2.0-or-later license permits commercial use but requires source disclosure for modifications.

Use it for:

  • Automate VM lifecycle management (create, start, stop, destroy) on KVM/QEMU hypervisors from Python scripts
  • Monitor and query running virtual machines and containers (LXC) to retrieve resource usage and status
  • Build cloud orchestration or infrastructure-as-code tools that need to control libvirt-managed virtualization
  • Integrate VM provisioning into Python-based deployment or testing frameworks

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides Python bindings to the libvirt virtualization API, allowing Python applications to manage virtual machines and containers on Linux and other operating systems.

Yes, if you need to manage libvirt-controlled VMs or containers from Python and your system already has libvirt installed. The high install friction (compiled dependency) is a real barrier—verify that your platform has prebuilt wheels or that you can satisfy the build requirements before attempting installation. For systems without libvirt or build tools, the installation will fail.

Install

libvirt-python on PyPI

pip

pip install libvirt-python

uv

uv add libvirt-python

poetry

poetry add libvirt-python

Installing libvirt-python

Before you install

High install friction: requires GCC, pkg-config, and libvirt development headers to compile from source. The package is actively maintained (released 11 days ago) and classified as Production/Stable, but the compiled dependency barrier means installation success depends on your system's build toolchain and libvirt libraries being present.

License in practice

Licensed under LGPL-v2.0-or-later (copyleft). You may use and modify this package freely, but any derivative work must also be distributed under LGPL or a compatible license, and source code must be made available to recipients.

Quickstart

# Install (requires libvirt dev headers and build tools)
pip install libvirt-python

# Basic usage
import libvirt
conn = libvirt.open('qemu:///system')
doms = conn.listAllDomains()
conn.close()

Requires GCC, pkg-config, and libvirt development headers (libvirt-devel or libvirt-dev) installed on your system before pip install will succeed.

Verify before relying

  • Whether prebuilt wheels are available for common platforms to avoid compilation
  • Specific libvirt version compatibility beyond the stated minimum of 0.9.11
  • Performance characteristics or scalability limits for large-scale VM management

Package facts

License LGPL-v2.0-or-later (copyleft)
Python support supports the current Python release (>=3.6)
Install friction high — source build required
Runtime dependencies none
Maintenance actively maintained — 11 days since the last release
First released
Downloads 323,552/month — #7,604 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: libvirt_python-12.6.0.tar.gz

Development Status :: 5 - Production/StableIntended Audience :: DevelopersProgramming Language :: Python :: 3 :: Only

Tags

libvirt python bindingsvirtualization management pythonkvm qemu lxc python apivirtual machine control pythonlibvirt api wrapperpython vm managementhypervisor control python
virtualizationsystem-administration

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

kcli

kcli is a command-line provisioning and…

unclear · top 15,000 on PyPI

pyobjc-framework-Virtualization

Provides Python bindings to macOS's…

permissive · top 15,000 on PyPI

azure-mgmt-desktopvirtualization

Manages Azure Desktop Virtualization resources…

permissive · top 15,000 on PyPI

qemu.qmp

A Python asyncio library for sending QMP (QEMU…

copyleft · top 15,000 on PyPI

cot

COT edits and deploys Open Virtualization…

permissive · top 15,000 on PyPI

python-rrmngmnt

Manages remote Linux machines and services over…

copyleft · top 15,000 on PyPI

docker-py

A Python client library that lets you control…

permissive · top 5,000 on PyPI

dissect.hypervisor

Parses hypervisor disk, backup, and…

agpl · top 15,000 on PyPI

systemd-python

Provides Python bindings to systemd's native C…

copyleft · top 5,000 on PyPI

rpm

Provides access to system RPM Python bindings…

permissive · top 15,000 on PyPI