Library / SDK
igraph/python-igraph avatar
igraph/python-igraph

igraph for Python: Graph Analysis, Installation, and Native Linking

Python interface for igraph

1,465 stars273 forksPythonGPL-2.0

At a glance

What is it?
python-igraph exposes the igraph C library through Python for graph construction, manipulation, and network analysis. It offers PyPI wheels for common Python installations, while source builds and external-core linking add native-toolchain requirements.
Who is it for?
Adopt python-igraph when Python-based graph analysis needs the native igraph library and your target platform has a suitable wheel. Do not choose it if an external C-core install or GraphML-enabled Windows build adds unnecessary system complexity.
Can I use it commercially?
Yes, with conditions. GPL-2.0 is a copyleft licence: if you distribute software that includes it, you must release that software's source code under the same licence. Running it internally without distributing it does not trigger that obligation.
Is it still maintained?
Yes. The repository last received commits 17 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What python-igraph Solves for Python Network Analysis

python-igraph gives Python programs access to igraph, a library for creating and manipulating graphs. It is intended for graph-theoretic and network-analysis work involving complex networks, relationships, connectivity, and other graph data. The project targets developers and researchers who want to express graph operations in Python while relying on the igraph C core rather than implementing graph storage and algorithms directly in Python.

The repository is the source for the Python interface, not a separate pure-Python graph implementation. The package includes source code for the matching igraph C core under `vendor/source/igraph`. Depending on platform, installation either uses a prebuilt wheel or compiles that native core and the Python extension. This distinction matters when choosing python-igraph for scripts, notebooks, services, or research software because the operating system, Python version, and desired build options affect installation.

The package requires Python 3.9 or later, as stated by `setup.py`. The README says that wheels are aimed at most stock Python versions, typically at least the three most recent Python 3 minor releases. A wheel normally avoids compilation during installation, but that does not mean every Python and platform combination has a matching binary package. Environments outside the wheel coverage need a compiler and the relevant native dependencies.

How the Python Bindings Reach the igraph C Core

The package architecture has two principal layers. Python code calls the `igraph` interface, while the compiled extension communicates with the igraph C library that implements graph operations. During a normal source build, `setup.py` and the `setuptools` build backend compile the vendored C core together with the Python extension. The project declares `setuptools` and `cmake>=3.18` in `pyproject.toml`, so an installation from source requires a working Python build environment rather than only copying Python files.

A second supported path links the Python interface to an already compiled igraph C core. The README says this custom installation must be discoverable by `pkg-config`, and compatibility is guaranteed only with the same C-core version vendored inside `vendor/source/igraph`. This is primarily aimed at Linux distribution maintainers that want the Python package to use the system igraph library instead of carrying its own copy. The README also identifies this path as useful on macOS with an igraph installation from Homebrew.

The `IGRAPH_USE_PKG_CONFIG=1` environment variable selects the external library. Without it, `pip install igraph` builds the vendored C core. External linking does not work with MSVC because MSVC lacks the required `pkg-config` support. The repository also includes tox, tests, documentation, and GitHub Actions configuration, but the README does not document a distinct runtime service or network protocol. The principal data path is therefore local Python calls into a native graph library.

Installing igraph with pip and Performing a First Check

The simplest documented installation uses the `igraph` package from PyPI. The README says this should normally install without compiling anything when a suitable wheel exists for the current Python version and platform:

bash
pip install igraph

The README does not provide a specific first-use script or output example. It links to the current documentation on Read the Docs, where graph construction and manipulation APIs are documented. The repository's `tests` directory is also present, but the README does not specify a single test command that can serve as a universal first-use check.

A user can confirm that `pip` completed successfully and then consult the version-specific documentation for graph creation, vertex and edge operations, and algorithms. If installation unexpectedly invokes a compiler, the normal wheel assumption did not hold for that environment. The README gives separate source-build routes for Debian and Ubuntu derivatives and for Windows. Those routes carry additional native-toolchain requirements, so the correct next step depends on the platform and whether GraphML support is required.

Debian and Ubuntu Source Builds for python-igraph

When a wheel is unavailable, the README gives a Debian and Ubuntu path. Install the compiler toolchain, Python development files, libxml2 headers, and zlib development files first:

bash
sudo apt install build-essential python-dev libxml2 libxml2-dev zlib1g-dev

After the dependencies are present, run the package installer again:

bash
pip install igraph

According to the README, this compiles both the C core of igraph and the Python extension automatically. That makes the command convenient, but it also shifts maintenance responsibility to the local build environment. Compiler availability, compatible headers, and package-manager differences can determine whether installation succeeds. The documented command is also operating-system-specific, so applying it unchanged to macOS or Windows would not be appropriate.

The presence of `libxml2` is particularly relevant to GraphML support. On Unix-like source builds, the README explicitly includes `libxml2` and `libxml2-dev` in the dependency command. The documentation does not explain every import format or provide a GraphML example in the README, so it does not establish that installing GraphML support alone creates or validates a GraphML workflow. It only confirms that the native build dependency is part of the documented setup.

Windows Builds and the Separate GraphML Requirement

The README describes source builds under Windows, while `setup.py` sets the current package minimum at Python 3.9. Microsoft Visual Studio 2015 or later is required for the documented build path. It also documents architecture selection through `IGRAPH_CMAKE_EXTRA_ARGS`. The value can select `Win32` for a 32-bit build or `x64` for a 64-bit build:

bash
set IGRAPH_CMAKE_EXTRA_ARGS=-A [arch]

Replace `[arch]` with the architecture required by the target Python environment. GraphML is disabled by default on Windows because the standard Windows installation does not provide `libxml2`. The documented `vcpkg.exe` installation command for a 64-bit static library is:

bash
vcpkg.exe install libxml2:x64-windows-static-md

The build must then be configured with the vcpkg toolchain, library path, static extension setting, and additional native libraries. These settings include `IGRAPH_EXTRA_LIBRARIES=libxml2,lzma,zlib,iconv,charset` and the exact vcpkg placeholder syntax documented in the README. A previously configured source tree may need to be cleaned before rebuilding, because the README warns that a build made without GraphML will not update the build automatically.

This is the sharpest installation limitation in the README. A Windows user who only needs ordinary graph operations can try the wheel route first. GraphML support introduces vcpkg, environment variables, architecture selection, and a clean rebuild. The documentation does not claim that every Windows configuration is equally supported.

Linking to an Existing igraph Installation

python-igraph can use an existing compiled C installation rather than its vendored copy. The first check is whether `pkg-config` can locate igraph and return compiler and linker flags:

bash
pkg-config --cflags --libs igraph

If that command returns flags rather than an error, the README says it is probably possible to proceed. Set `IGRAPH_USE_PKG_CONFIG=1` for the installation command:

bash
IGRAPH_USE_PKG_CONFIG=1 pip install igraph

For a downloaded source tree, the equivalent command uses the local directory:

bash
IGRAPH_USE_PKG_CONFIG=1 pip install .

The environment variable must be present for both documented invocations. Without it, the build system uses the vendored C core. This route is not a generic guarantee that any installed igraph will work with any python-igraph release. The README specifically states that the interface is guaranteed to work only with the same C-core version vendored in the package.

For maintainers, the trade-off is packaging control. Linking to a system library can avoid carrying a second copy of igraph, but it adds discovery, version alignment, and compiler-linker requirements. MSVC is excluded because `pkg-config` support is unavailable. On macOS, the README identifies Homebrew as a relevant source of an existing igraph installation.

Limits, Maintenance, and Upgrade Boundaries

The most significant limitations are native-build and version compatibility, not missing Python packaging entry points. A wheel avoids compilation only when the environment matches an available PyPI wheel. A source build requires the toolchain described by the operating system. External linking requires `pkg-config`, an already compiled C core, and a compatible version. Windows GraphML support is not included by default because `libxml2` is absent from the standard Windows installation.

The project is not archived. The last push was on 2026-10-06, so the repository has a recent maintenance signal. That fact does not eliminate upgrade work. The package contains a compiled extension and a native core, and its README warns about compatibility between the Python interface and C core. Upgrading python-igraph can therefore involve Python-version support, wheel availability, C-core changes, or native dependencies.

The repository declares the GPL-2.0 license. That is a licensing condition to account for when distributing or incorporating the package, but this article does not offer legal advice. The README also specifies a research citation for Csardi and Nepusz, which is relevant to users publishing work based on igraph.

A practical alternative is to use a pure-Python or application-specific graph implementation when native compilation, ABI alignment, or C-core packaging is undesirable. That approach can be simpler for a small custom graph, but the README does not claim feature parity or performance parity with igraph. The appropriate alternative depends on which algorithms and native operations the project actually needs.

Editorial conclusion

Adopt python-igraph when Python-based graph analysis needs the native igraph library and your target platform has a suitable wheel. Do not choose it if an external C-core install or GraphML-enabled Windows build adds unnecessary system complexity. Verify first whether `pip install igraph` provides a wheel for your Python version and operating system, then check native libraries only if compilation or external linking is unavoidable.

Frequently asked questions

How do I install igraph for Python?

Run `pip install igraph`. The README says a PyPI wheel should normally avoid compilation for supported Python versions and platforms; otherwise, use the documented source-build steps.

Does python-igraph require Python 3.9 or later?

Yes. The `setup.py` check states that the module requires Python >= 3.9 and exits when the interpreter is older.

Can python-igraph use an existing igraph C installation?

Yes, if the installation is discoverable with `pkg-config` and its version is compatible with the interface. Set `IGRAPH_USE_PKG_CONFIG=1` during installation. The README says this method does not work with MSVC.

Why is GraphML disabled by default on Windows?

The README says GraphML is disabled by default because `libxml2` is not available in the standard Windows installation. It documents installing `libxml2` with `vcpkg` and configuring the build with additional environment variables.

Official sources

  1. igraph/python-igraph on GitHub
  2. License: GPL-2.0
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/igraph-python-igraph.svg)](https://hysenlabs.com/projects/igraph-python-igraph)

Was this useful?