{"id":10186,"library":"qiskit-qasm3-import","title":"Qiskit OpenQASM 3 Importer","description":"The `qiskit-qasm3-import` library provides functionality to parse OpenQASM 3 strings into Qiskit circuits, enabling interoperability between QASM 3 programs and the Qiskit ecosystem. It is currently at version 0.6.0 and releases new minor versions periodically, typically in conjunction with Qiskit's major releases or to add support for new QASM 3 features.","status":"active","version":"0.6.0","language":"en","source_language":"en","source_url":"https://github.com/Qiskit/qiskit-qasm3-import","tags":["qiskit","qasm3","quantum-computing","parser","compiler"],"install":[{"cmd":"pip install qiskit-qasm3-import","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This library generates Qiskit circuits and is designed to integrate with the Qiskit ecosystem. Specific versions of `qiskit-qasm3-import` are tied to compatible Qiskit versions.","package":"qiskit","optional":false}],"imports":[{"symbol":"loads","correct":"from qiskit_qasm3_import import loads"}],"quickstart":{"code":"from qiskit_qasm3_import import loads\n\nqasm3_str = \"\"\"\nOPENQASM 3.0;\ninclude \"qelib1.inc\";\nqreg q[2];\ncreg c[2];\nh q[0];\ncx q[0], q[1];\nmeasure q -> c;\n\"\"\"\n\n# Parse the QASM 3 string into a Qiskit QuantumCircuit\ncircuit = loads(qasm3_str)\n\n# Print a summary of the resulting circuit\nprint(circuit.draw('text', idle_wires=False))","lang":"python","description":"Parse an OpenQASM 3 string into a Qiskit `QuantumCircuit` object using the `loads` function."},"warnings":[{"fix":"Upgrade to `qiskit-qasm3-import>=0.6.0` when using Qiskit 1.0.0 or later: `pip install --upgrade qiskit-qasm3-import`.","message":"Version 0.6.0 of `qiskit-qasm3-import` introduced compatibility with Qiskit 1.0.0. If you are using an older version of `qiskit-qasm3-import` (e.g., <0.6.0) with Qiskit 1.0.0+, you may encounter errors related to API changes or an incompatible `QuantumCircuit` object structure.","severity":"breaking","affected_versions":"<0.6.0"},{"fix":"Refer to the official documentation and GitHub repository for the list of currently supported OpenQASM 3 features. For unsupported features, consider simplifying your QASM 3 code or reporting an issue to the project.","message":"The `qiskit-qasm3-import` library does not currently support all features defined by the OpenQASM 3 specification. Complex or less common QASM 3 constructs might lead to parsing errors or incomplete circuit representations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that the input to `qiskit_qasm3_import.loads()` is a valid string containing the OpenQASM 3 code. To load from a file, read the file content into a string first (e.g., `with open('my_circuit.qasm', 'r') as f: qasm_str = f.read()`).","message":"The `loads` function expects a string as input. Providing a file path or an object that is not a string will result in a `TypeError` or a parsing failure.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install the package using pip: `pip install qiskit-qasm3-import`","cause":"The `qiskit-qasm3-import` package is not installed in your Python environment.","error":"ModuleNotFoundError: No module named 'qiskit_qasm3_import'"},{"fix":"Change `qiskit_qasm3_import.parse(...)` to `qiskit_qasm3_import.loads(...)`.","cause":"You are trying to call a function named `parse`, which does not exist. The correct function for parsing a QASM 3 string is `loads`.","error":"AttributeError: module 'qiskit_qasm3_import' has no attribute 'parse'"},{"fix":"If using Qiskit 1.0.0 or later, ensure `qiskit-qasm3-import` is version 0.6.0 or newer: `pip install --upgrade qiskit-qasm3-import`. If using an older Qiskit Terra, ensure `qiskit-qasm3-import` is compatible (typically <0.6.0).","cause":"There is a version mismatch between your installed `qiskit` and `qiskit-qasm3-import` packages. This error specifically points to the required compatibility.","error":"qiskit.exceptions.QiskitError: 'OpenQASM 3 circuits from this importer require Qiskit Terra >= 0.24.0 and < 1.0.0 for qiskit-qasm3-import < 0.6.0, or Qiskit >= 1.0.0 for qiskit-qasm3-import >= 0.6.0.'"}]}