Registry / devops / pkgconfig

pkgconfig

JSON →
library1.6.0pypypi✓ verified 24d ago

pkgconfig is a Python library that provides a simple interface to the `pkg-config` command-line tool. It allows Python applications to query installed libraries for their build flags (Cflags, Libs) and version information, making it easier to build and link against external C/C++ libraries. The current version is 1.6.0, and it has an infrequent release cadence, typically releasing new versions only when significant updates or fixes are needed.

pip install pkgconfig
INSTALL
IMPORT
SIG · PKGCONFIG
P
pkgconfig
devopspythonv1.6.0
Install
1.6s avg
Import
16ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.016s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.016s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pkgconfig
import pkgconfig

This quickstart demonstrates how to check for a package's existence, retrieve its CFLAGS and LIBS, get its version, and parse all available information into a dictionary using `pkgconfig.parse().`

import pkgconfig # Check if a package exists if pkgconfig.exists('glib-2.0'): print('glib-2.0 is installed.') # Get CFLAGS for compilation cflags = pkgconfig.cflags('glib-2.0') print(f'CFlags: {cflags}') # Get LIBS for linking libs = pkgconfig.libs('glib-2.0') print(f'Libs: {libs}') # Get the package version version = pkgconfig.modversion('glib-2.0') print(f'Version: {version}') # Parse all information into a dictionary parsed_info = pkgconfig.parse('glib-2.0') print(f'Parsed Info: {parsed_info}') else: print('glib-2.0 is not installed or not found by pkg-config.') # Example with a non-existent package to show handling if not pkgconfig.exists('nonexistent-library-xyz'): print('nonexistent-library-xyz is not found, as expected.')
Debug
Known issues
gotchaThe Python `pkgconfig` library is a wrapper around the system's `pkg-config` command-line tool. It requires the `pkg-config` executable to be installed and available in the system's PATH. This library does not install `pkg-config` itself.
fix
Ensure that the `pkg-config` command-line tool is installed on your operating system (e.g., `sudo apt install pkg-config` on Debian/Ubuntu, `brew install pkg-config` on macOS, or via MSYS2/MinGW on Windows).
affects: All versions
gotchaThis library only reads existing `.pc` files that `pkg-config` knows about. It does not provide functionality to install new `.pc` files or manage `pkg-config` package definitions. Its purpose is solely to query system-level `pkg-config` data.
fix
If you need to define new packages for `pkg-config` to find, you must manually create and place `.pc` files in a directory included in `PKG_CONFIG_PATH`.
affects: All versions
deprecatedThe `pkgconfig.VARIABLES` attribute was removed in version 1.4.0. To access package variables, use the `pkgconfig.parse()` function and retrieve them from the returned dictionary via the `'Variables'` key (e.g., `pkgconfig.parse('foobar')['Variables']`).
fix
Replace calls to `pkgconfig.VARIABLES` with `pkgconfig.parse('your_package')['Variables']`.
affects: >=1.4.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pkgconfig'
The Python 'pkgconfig' library has not been installed in the current Python environment.
fix
pip install pkgconfig
pkg-config probably not installed: FileNotFoundError(2, 'No such file or directory') (or similar messages like '/bin/sh: pkg-config: not found')
The underlying 'pkg-config' command-line tool, which the Python 'pkgconfig' library wraps, is not installed on the system or is not accessible in the system's PATH.
fix
Install the 'pkg-config' command-line tool using your system's package manager (e.g., 'sudo apt install pkg-config' for Debian/Ubuntu, 'sudo yum install pkgconfig' for RedHat/CentOS, 'brew install pkg-config' for macOS).
Package <some_package> was not found in the pkg-config search path. Perhaps you should add the directory containing `<some_package>.pc' to the PKG_CONFIG_PATH environment variable
The 'pkg-config' command-line tool is installed, but it cannot locate the '.pc' file for the specified library, often because the directory containing the '.pc' file is not included in the 'PKG_CONFIG_PATH' environment variable.
fix
Set the PKG_CONFIG_PATH environment variable to include the directory where the '.pc' file for the missing package is located (e.g., 'export PKG_CONFIG_PATH=/path/to/lib/pkgconfig:$PKG_CONFIG_PATH').
'pkg-config' is required to install this package
This error occurs during the installation of another Python package that has a build dependency on the 'pkg-config' command-line tool, but 'pkg-config' is not available on the system.
fix
Install the 'pkg-config' command-line tool using your system's package manager (e.g., 'sudo apt install pkg-config') before attempting to install the Python package again.
Upgrade
Version history
1.6.0latest on PyPI · released Mar 6, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
pkgconfig — pip install pkgconfig · libregistry