openqasm
An OpenQASM 2.0 parser for Python.
This is the
v2branch, which holds the OpenQASM 2 parser (openqasm2.x on PyPI). OpenQASM 3 lives onmaster(openqasm3.x).
Installation
pip install "openqasm<3"
To export expressions to LaTeX, install the optional extra:
pip install "openqasm[latex]<3".
Usage
from openqasm import Qasm
file_path = '/path/to/file.qasm'
# Parse the QASM file
qasm = Qasm(file_path)
# Get AST
ast = qasm.parse()
# Print the parsed QASM with precision=15
print(ast.qasm(15))
The bundled qelib1.inc is the final version of the IBM/Qiskit standard
header. It contains every gate of the specification's qelib1.inc plus newer
gates (sx, rxx, cu, ...). Programs that define those newer gates
themselves keep working: their definition replaces the bundled one.
Development
pip install -e ".[test,latex]"
pytest
See CHANGELOG.md for changes.
License
Apache 2.0
Metadata
Release files for openqasm 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openqasm-2.0.0.tar.gz | 33.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openqasm-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 94.8 kB
Release files / openqasm-2.0.0.tar.gz
| Download URL | openqasm-2.0.0.tar.gz |
|---|---|
| Size | 33.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e46e372b2f97a2a4d11e4dfb061641ab04c224e30bbd46c1a3e070dc4fcd1fa4
|
|
BLAKE2b-256 checksum How to use checksums |
d0420ed187aff33a3028607ffdd3328fc1ae34c4d584e13755f6b62429ba0267
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency logRelease files / openqasm-2.0.0-py3-none-any.whl
| Download URL | openqasm-2.0.0-py3-none-any.whl |
|---|---|
| Size | 61.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6bfeee6b28b3fe3f34555ef001a1833003f075439ea6e20961fc60b5dba2e5d3
|
|
BLAKE2b-256 checksum How to use checksums |
ecf8957c0f42dc4297983f44187ebd8134bacfc6a804896c2850505c41c166f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.
Transparency log