Registry / serialization / oqpy
library0.3.10pypypi✓ verified 84d ago

oqpy is a Python library for generating OpenQASM 3 + OpenPulse programs programmatically. Current version is 0.3.10, with a monthly-to-quarterly release cadence.

pip install oqpy
INSTALL
IMPORT
SIG · OQPY
O
oqpy
serializationpythonv0.3.10
Install
5.0s avg
Import
890ms
Disk
104MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.3.10 · 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.896s · 102.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.0s · import 0.884s · 99MB
104MB installed
● package 104MB
Code
Verified usage

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

Program
from oqpy import Program
from oqpy.program import Program
Program is exported at the top-level oqpy package.
Measurement
from oqpy import Measurement
No common mistake.

Create a simple OpenQASM 3 program with two qubits, apply Hadamard, and measure.

from oqpy import Program # Create a quantum program program = Program() # Declare a qubit register q = program.declare_qubit('q', size=2) # Add a gate program.gate("h", q[0]) # Measure program.measure(q[0], program.declare_bit('c')) # Output OpenQASM 3 print(program.to_qasm())
Debug
Known issues
breakingIn v0.3.0, the API for declaring variables changed. Use `program.declare_qubit()` instead of `program.qubit()`.
fix
Update to use `declare_qubit`, `declare_bit`, `declare_float`, etc.
affects: <0.3.0
deprecatedThe `extern` function signature changed; now requires `return_type` parameter.
fix
Add `return_type` argument to `program.extern()` calls.
affects: <0.3.5
gotchaWhen using array indexing, results in oqpy types are not automatically converted to Python slices. Use `oqpy.slice()` to avoid bugs.
fix
Use `oqpy.slice(start, stop, step)` instead of Python's built-in slice.
affects: >=0.3.2
gotchaDuration literals must be constructed with `oqpy.DurationLiteral(value, unit)`; plain numbers are not automatically converted.
fix
Always use `DurationLiteral` for duration values.
affects: *
Errors
Common errors & fixes
AttributeError: module 'oqpy' has no attribute 'Program'
Incorrect import: many examples online use `from oqpy.program import Program` but the correct import is `from oqpy import Program`.
fix
Use `from oqpy import Program`.
TypeError: extern() missing 1 required positional argument: 'return_type'
In oqpy 0.3.5+, `extern()` requires a `return_type` argument.
fix
Add `return_type` to extern declaration, e.g., `program.extern('my_extern', return_type=oqpy.FloatVar)`.
ValueError: Cannot convert value 0 to an OQPY duration
Using plain integers/float where a duration type is expected.
fix
Wrap the value in `DurationLiteral`, e.g., `oqpy.DurationLiteral(0, 'ns')`.
Upgrade
Version history
0.3.10latest on PyPI · released Feb 25, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
oqpy — pip install oqpy · libregistry