{"id":7721,"library":"sip","title":"SIP - Python Bindings Generator","description":"SIP is a tool for creating Python bindings for C and C++ libraries. It is primarily used to generate Python modules that allow Python code to call C/C++ functions and classes directly. Maintained by Riverbank Computing, it is the foundation for PyQt. The current version is 6.15.3, with releases typically tied to PyQt development.","status":"active","version":"6.15.3","language":"en","source_language":"en","source_url":"https://www.riverbankcomputing.com/software/sip/","tags":["bindings","c++","c","generator","pyqt","build-tool"],"install":[{"cmd":"pip install sip","lang":"bash","label":"Install SIP"}],"dependencies":[],"imports":[{"note":"The 'setapi' function was removed in SIP v6. API version is now handled by sip-build and directives in .sip files.","wrong":"from sip import setapi","symbol":"sip module","correct":"import sip"},{"note":"When using a SIP-based library like PyQt, its specific SIP API might be exposed within its own namespace for internal use or advanced features.","symbol":"SIP API from PyQt","correct":"from PyQt6 import sip"}],"quickstart":{"code":"import sip\n\n# SIP is primarily a C/C++ bindings generator, not typically used directly in applications.\n# This example shows basic introspection of the installed sip module.\n\nprint(f\"SIP Version: {sip.SIP_VERSION_STR}\")\nprint(f\"SIP API ID: {sip.SIP_API_ID_STR}\")\n\n# To truly 'quickstart' SIP for generating bindings, you would:\n# 1. Write a .sip file defining the C/C++ API.\n# 2. Use the 'sip-build' command-line tool or integrate it into your build system.\n# Example (conceptual command-line use):\n# # In a terminal, after setting up project.sip and C/C++ sources:\n# # sip-build --build-dir=build --sip-module=my_module project.sip","lang":"python","description":"While SIP is mainly a build tool for C/C++ extensions, the installed `sip` module provides introspective information about the SIP environment. The primary use case involves defining `.sip` files and leveraging the `sip-build` command-line tool to generate Python bindings for a C/C++ library, typically as part of a larger build process."},"warnings":[{"fix":"Migrate your binding generation process to use `sip-build`. Remove calls to `sip.setapi()` from your `.sip` files or generated Python code. Consult the SIP v6 documentation for updated `.sip` file directives and build configurations (e.g., `PyQt-builder`).","message":"SIP v6 introduced significant breaking changes from v5, including the removal of `sip.setapi()` and the standalone `sipconfig` module. The API versioning and configuration are now implicitly handled during the build process using the `sip-build` tool.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Ensure that the `sip` package version precisely matches the requirements of the Python library you are using (e.g., PyQt, PySide). If you manage multiple Python environments, use virtual environments to isolate dependencies. Always upgrade `sip` alongside the primary library it serves.","message":"Mixing SIP versions or using a `sip` module incompatible with a generated library (e.g., PyQt) can lead to `ImportError` or `RuntimeError` due to ABI incompatibilities. For example, PyQt5 typically uses SIP v4/v5, while PyQt6 requires SIP v6.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Verify compiler installations, associated environmental variables (e.g., `VCINSTALLDIR` for MSVC, `PATH` for GCC/Clang), and ensure build tools are available. Common issues include 'Microsoft Visual C++ 14.0 is required' errors on Windows, or missing `g++` on Linux.","message":"When building C/C++ extensions with SIP, ensure your development environment has a compatible C++ compiler (e.g., MSVC on Windows, GCC/Clang on Linux/macOS) and that necessary build tools (like `make` or `ninja`) are correctly configured and accessible in your system's PATH.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"This function is obsolete in SIP v6. API versioning is now implicitly managed by the `sip-build` tool during the binding generation process. Remove any `setapi` calls from your Python code or `.sip` files.","cause":"Attempting to call the `setapi` function which was removed in SIP v6.","error":"AttributeError: module 'sip' has no attribute 'setapi'"},{"fix":"Install the latest Microsoft Visual C++ Redistributable for your system. Verify your Python installation's integrity. If in a virtual environment, try recreating it and reinstalling `sip`. For C/C++ projects, ensure they are compiled with compatible toolchains.","cause":"This error on Windows typically indicates a missing or incompatible C++ runtime library (e.g., Visual C++ Redistributable), an issue with the Python environment path, or a corrupted `sip` installation.","error":"ImportError: DLL load failed while importing sip"},{"fix":"Ensure you are using a version of `sip` compatible with PyQt5 (typically v4 or v5). PyQt6 does not use `setapi` and would not yield this error. Check your `pip freeze` output and consider isolating Python environments with `venv` or `conda`.","cause":"This error occurs specifically with PyQt5 when the underlying SIP API is not correctly configured or when attempting to use a SIP v6 module with a PyQt5 installation.","error":"RuntimeError: The PyQt5.sip API has not been set."}]}