{"id":24381,"library":"pyquil","title":"PyQuil","description":"PyQuil is a Python library for creating and running Quantum Instruction Language (Quil) programs on Rigetti quantum processors and simulators. The current version is 4.17.0, supporting Python 3.9-3.12. It sees regular releases alongside Rigetti's Forest SDK.","status":"active","version":"4.17.0","language":"python","source_language":"en","source_url":"https://github.com/rigetti/pyquil","tags":["quantum computing","quil","rigetti","quantum instruction language","simulator"],"install":[{"cmd":"pip install pyquil","lang":"bash","label":"Standard install"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"Program","correct":"from pyquil import Program"},{"note":"In v4.x, get_qc is a top-level import; the submodule path changed.","wrong":"from pyquil.api import get_qc","symbol":"get_qc","correct":"from pyquil import get_qc"},{"note":"Common mistake due to old docs; correct module is pyquil.api.","wrong":"from pyquil.compiler import AbstractCompiler","symbol":"AbstractCompiler","correct":"from pyquil.api import AbstractCompiler"}],"quickstart":{"code":"from pyquil import Program, get_qc\nfrom pyquil.gates import H, CNOT, MEASURE\n\n# Create a Bell state program\np = Program()\np += H(0)\np += CNOT(0, 1)\nro = p.declare('ro', 'BIT', 2)\np += MEASURE(0, ro[0])\np += MEASURE(1, ro[1])\n\n# Get a quantum computer (simulator)\nqc = get_qc('2q-qvm')\n\n# Run the program\nexecutable = qc.compile(p)\nresult = qc.run(executable)\nprint(result.readout.get('ro'))","lang":"python","description":"Minimal example creating a Bell state circuit and running on the QVM simulator."},"warnings":[{"fix":"Update import statements and use `qc.compile(program)` before running.","message":"PyQuil 4.x introduced breaking changes from 3.x: import paths changed (e.g., `from pyquil.api` instead of `from pyquil.quilbase`), and the `QuantumComputer.run()` now expects compiled executables, not programs.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Switch to the new import paths; see migration guide.","message":"The `from pyquil.quil` module and `from pyquil.parser` are deprecated in 4.x. Use `from pyquil import Program` and `from pyquil.gates` for gate definitions.","severity":"deprecated","affected_versions":">=4.0.0 <5.0.0"},{"fix":"Ensure the QVM server is running: `qvm -S` in a separate terminal, or use a remote QPU endpoint.","message":"When using `get_qc('2q-qvm')`, the QVM (quantum virtual machine) is a simulator that requires the QVM server to be running locally or via Forest SDK. Without it, calls to `run` will hang or fail with connection errors.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'-3.12':30 '3.9':29 '4.17.0':26 'alongsid':35 'comput':41 'creat':8 'current':23 'forest':38 'instruct':12,45 'languag':13,46 'librari':6 'processor':19 'program':15 'pyquil':1,2 'python':5,28 'quantum':11,18,40,44 'quil':14,42 'regular':33 'releas':34 'rigetti':17,36,43 'run':10 'sdk':39 'see':32 'simul':21,47 'support':27 'version':24","created_at":"2026-05-01T08:12:46.778326+00:00","updated_at":"2026-05-01T08:12:46.778326+00:00","problems":[{"fix":"Use `from pyquil import get_qc` for the quantum computer object; API classes are under `pyquil.api` but may require separate import.","cause":"Incorrect import path: users try `from pyquil.api import ...` but the module is not installed or deprecated in older versions.","error":"ModuleNotFoundError: No module named 'pyquil.api'"},{"fix":"Replace `program.run(qc)` with `qc.compile(program)` then `qc.run(executable)`.","cause":"In PyQuil 4.x, programs are not directly runnable; they must be compiled first.","error":"AttributeError: 'Program' object has no attribute 'run'"},{"fix":"Set shots via `program.wrap_in_numshots_loop(N)` before compiling.","cause":"In PyQuil 4.x, the `run()` method no longer accepts `shots`; the number of shots is set in the program via `measurements` or in the `compile` step.","error":"TypeError: 'QuantumComputer.run()' got an unexpected keyword argument 'shots'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.17.0","cli_name":"","cli_version":null,"type":"library","homepage":"https://www.rigetti.com","github":"https://github.com/rigetti/pyquil.git","docs":"https://pyquil-docs.rigetti.com","changelog":null,"pypi":"https://pypi.org/project/pyquil/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}