{"id":21652,"library":"openfermion","title":"OpenFermion","description":"OpenFermion is an open-source library for quantum chemistry simulation on quantum computers. Version 1.7.1 (requires Python >=3.10) provides tools for mapping fermionic Hamiltonians to qubit operators, variational quantum eigensolver (VQE) workflows, and interfaces to quantum computing SDKs. Released periodically, approximately quarterly.","status":"active","version":"1.7.1","language":"python","source_language":"en","source_url":"https://github.com/quantumlib/OpenFermion","tags":["quantum computing","quantum chemistry","fermions","hamiltonian","vqe"],"install":[{"cmd":"pip install openfermion","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Used for quantum circuit simulation and interfaces","package":"cirq","optional":true},{"reason":"Provides molecular data and integrals","package":"pyscf","optional":true},{"reason":"Numerical computing backbone","package":"numpy","optional":false}],"imports":[{"note":"Deprecated path; function is now at top-level","wrong":"from openfermion.ops import get_sparse_operator","symbol":"get_sparse_operator","correct":"from openfermion import get_sparse_operator"},{"note":"Moved to top-level in v1.0+","wrong":"from openfermion.utils import qubit_operator_sparse","symbol":"qubit_operator_sparse","correct":"from openfermion import qubit_operator_sparse"},{"note":"Deprecated submodule; use top-level import","wrong":"from openfermion.hamiltonians import MolecularData","symbol":"MolecularData","correct":"from openfermion import MolecularData"}],"quickstart":{"code":"import openfermion as of\n\n# Create a simple hydrogen molecule (minimal basis)\ngeometry = [('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.7414))]\nmolecule = of.MolecularData(geometry, basis='sto-3g', multiplicity=1, charge=0)\nmolecule.load()\n\n# Get the fermionic Hamiltonian\nhamiltonian = molecule.get_molecular_hamiltonian()\nprint(hamiltonian)\n\n# Map to qubit Hamiltonian (Jordan-Wigner)\nqubit_ham = of.jordan_wigner(hamiltonian)\nprint(qubit_ham)\n\n# Get sparse matrix\nsparse_mat = of.get_sparse_operator(qubit_ham)\nprint(sparse_mat.shape)","lang":"python","description":"Basic workflow: load molecular data, obtain fermionic Hamiltonian, map to qubit operator, and inspect sparse matrix representation."},"warnings":[{"fix":"Replace e.g. `from openfermion.ops import InteractionOperator` with `from openfermion import InteractionOperator`.","message":"In v1.0, many top-level imports changed from submodules (e.g., `openfermion.ops`, `openfermion.utils`) to direct `openfermion`. Code using old import paths will break.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use `from openfermion import eigensolver` or `scipy.sparse.linalg.eigsh`.","message":"`get_ground_state` function is deprecated. Use `eigensolver` from `openfermion` or `scipy.sparse.linalg.eigsh`.","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"Always call `molecule.load()` after creating `MolecularData` object.","message":"When using `MolecularData`, the molecule must be loaded with `.load()` before accessing properties. Forgetting this raises an `AttributeError`.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `of.bravyi_kitaev(hamiltonian)` or `of.symmetric_jordan_wigner(hamiltonian)` to reduce qubit count or operator weight.","message":"The Jordan-Wigner transform of a large Hamiltonian can produce a very dense operator; consider using Bravyi-Kitaev or other transforms for efficiency.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add `molecule.load()` after constructing the MolecularData object.","cause":"MolecularData was not loaded. Accessing attributes before `.load()` fails.","error":"AttributeError: 'MolecularData' object has no attribute 'n_qubits'"},{"fix":"Use `from openfermion import InteractionOperator` (v1.0+) or `from openfermion.ops import InteractionOperator` (v0.x). Check your version.","cause":"In versions >=1.0, the import path changed. InteractionOperator is still available but must be imported from `openfermion.ops` only in older versions.","error":"ImportError: cannot import name 'InteractionOperator' from 'openfermion'"},{"fix":"Install with `pip install openfermionpyscf` and import as `import openfermionpyscf`.","cause":"openfermionpyscf is a separate plugin package for PySCF integration. Not included by default.","error":"ModuleNotFoundError: No module named 'openfermionpyscf'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}