{"id":24378,"library":"pyqir","title":"PyQIR","description":"A Python library for generating, parsing, and evaluating Quantum Intermediate Representation (QIR). Current version is 0.12.4, with irregular release cadence, typically 3-4 minor releases per year.","status":"active","version":"0.12.4","language":"python","source_language":"en","source_url":"https://github.com/qir-alliance/pyqir","tags":["quantum","qir","llvm","quantum-computing"],"install":[{"cmd":"pip install pyqir","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Builder","correct":"from pyqir import Builder"},{"note":"","wrong":"","symbol":"BasicBlock","correct":"from pyqir import BasicBlock"},{"note":"","wrong":"","symbol":"Context","correct":"from pyqir import Context"},{"note":"","wrong":"","symbol":"Module","correct":"from pyqir import Module"},{"note":"","wrong":"","symbol":"Qubit","correct":"from pyqir import Qubit"},{"note":"Also valid, but direct import is clearer.","wrong":"import pyqir; pyqir.__version__","symbol":"__version__","correct":"from pyqir import __version__"},{"note":"evaluate is a submodule.","wrong":"from pyqir import evaluate","symbol":"evaluate","correct":"from pyqir.evaluator import evaluate"},{"note":"SimpleEvaluator is in evaluator submodule.","wrong":"from pyqir import SimpleEvaluator","symbol":"SimpleEvaluator","correct":"from pyqir.evaluator import SimpleEvaluator"},{"note":"Provides access to QIR constants.","wrong":"","symbol":"__qir__","correct":"from pyqir import __qir__"}],"quickstart":{"code":"from pyqir import Builder, BasicBlock, Context, Module, Qubit\nfrom pyqir.evaluator import evaluate\n\ncontext = Context()\nmodule = Module(context)\nbuilder = Builder(context)\nentry = BasicBlock(context, \"entry\", module)\nbuilder.insert_at_end(entry)\nqubit = builder.add_qubit()\nbuilder.h(qubit)\nbuilder.mz(qubit)\nresult = evaluate(module, {})\nprint(result)","lang":"python","description":"Create a simple QIR module with a Hadamard and measurement, then evaluate it."},"warnings":[{"fix":"Use the latest API. See upgrade guide: https://github.com/qir-alliance/pyqir/blob/main/docs/upgrade.md#pyqir-012","message":"PyQIR 0.12.0 switched to QIR 2.0 with opaque pointer support, breaking modules generated with older versions. Upgrade your QIR generation code.","severity":"breaking","affected_versions":">=0.12.0"},{"fix":"Monitor docs for replacement APIs.","message":"The `evaluate` function and `SimpleEvaluator` may be deprecated in future versions. Prefer newer evaluation APIs if available.","severity":"deprecated","affected_versions":"<0.13?"},{"fix":"Keep a local reference to qubits or reset the builder context if needed.","message":"Qubit IDs are not automatically reset; calling `add_qubit()` increments an internal counter. When reusing a builder, qubit indices can become stale.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade Python to 3.9+ or use maturin to build from source.","message":"The library is compiled with Rust/PyO3; ensure your Python version is >=3.9. Pre-built wheels may not be available for all platforms (e.g., ARM Linux).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace 'from pyqir import evaluate' with 'from pyqir.evaluator import evaluate'","cause":"Trying to import evaluate directly from pyqir instead of pyqir.evaluator.","error":"AttributeError: module 'pyqir' has no attribute 'evaluate'"},{"fix":"Replace 'from pyqir import SimpleEvaluator' with 'from pyqir.evaluator import SimpleEvaluator'","cause":"SimpleEvaluator is in a submodule, not directly in pyqir.","error":"ImportError: cannot import name 'SimpleEvaluator' from 'pyqir'"},{"fix":"Upgrade to Python >=3.9 or build from source using maturin.","cause":"No prebuilt wheel for your platform (e.g., ARM Linux, Python 3.8).","error":"RuntimeError: Unable to find a prebuilt wheel for pyqir on this platform"},{"fix":"Ensure you create a Context first and pass it to all objects.","cause":"Builder or BasicBlock was used before being properly initialized.","error":"AttributeError: 'NoneType' object has no attribute 'context'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}