Registry / ai-ml / openfermion

openfermion

JSON →
library1.7.1pypypi✓ verified 84d ago

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.

pip install openfermion
INSTALL
IMPORT
SIG · OPENFERMION
O
openfermion
ai-mlpythonv1.7.1
Install
24.8s avg
Import
8587ms
Disk
602MB
Pass rate
9/ 10
Env Coverage9 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.1 · 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
glibc
py 3.10
✓ —
✓ 23.7s
py 3.11
✓ —
✓ 23.4s
py 3.12
✓ —
✓ 24.5s
py 3.13
✓ —
✓ 24.9s
py 3.9
✕ build_error
✓ 27.5s
602MB installed
● package 602MB
Code
Verified usage

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

get_sparse_operator
from openfermion import get_sparse_operator
from openfermion.ops import get_sparse_operator
Deprecated path; function is now at top-level
qubit_operator_sparse
from openfermion import qubit_operator_sparse
from openfermion.utils import qubit_operator_sparse
Moved to top-level in v1.0+
MolecularData
from openfermion import MolecularData
from openfermion.hamiltonians import MolecularData
Deprecated submodule; use top-level import

Basic workflow: load molecular data, obtain fermionic Hamiltonian, map to qubit operator, and inspect sparse matrix representation.

import openfermion as of # Create a simple hydrogen molecule (minimal basis) geometry = [('H', (0.0, 0.0, 0.0)), ('H', (0.0, 0.0, 0.7414))] molecule = of.MolecularData(geometry, basis='sto-3g', multiplicity=1, charge=0) molecule.load() # Get the fermionic Hamiltonian hamiltonian = molecule.get_molecular_hamiltonian() print(hamiltonian) # Map to qubit Hamiltonian (Jordan-Wigner) qubit_ham = of.jordan_wigner(hamiltonian) print(qubit_ham) # Get sparse matrix sparse_mat = of.get_sparse_operator(qubit_ham) print(sparse_mat.shape)
Debug
Known issues
breakingIn 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.
fix
Replace e.g. `from openfermion.ops import InteractionOperator` with `from openfermion import InteractionOperator`.
affects: >=1.0.0
deprecated`get_ground_state` function is deprecated. Use `eigensolver` from `openfermion` or `scipy.sparse.linalg.eigsh`.
fix
Use `from openfermion import eigensolver` or `scipy.sparse.linalg.eigsh`.
affects: >=1.5.0
gotchaWhen using `MolecularData`, the molecule must be loaded with `.load()` before accessing properties. Forgetting this raises an `AttributeError`.
fix
Always call `molecule.load()` after creating `MolecularData` object.
affects: all
gotchaThe Jordan-Wigner transform of a large Hamiltonian can produce a very dense operator; consider using Bravyi-Kitaev or other transforms for efficiency.
fix
Use `of.bravyi_kitaev(hamiltonian)` or `of.symmetric_jordan_wigner(hamiltonian)` to reduce qubit count or operator weight.
affects: all
Errors
Common errors & fixes
AttributeError: 'MolecularData' object has no attribute 'n_qubits'
MolecularData was not loaded. Accessing attributes before `.load()` fails.
fix
Add `molecule.load()` after constructing the MolecularData object.
ImportError: cannot import name 'InteractionOperator' from 'openfermion'
In versions >=1.0, the import path changed. InteractionOperator is still available but must be imported from `openfermion.ops` only in older versions.
fix
Use `from openfermion import InteractionOperator` (v1.0+) or `from openfermion.ops import InteractionOperator` (v0.x). Check your version.
ModuleNotFoundError: No module named 'openfermionpyscf'
openfermionpyscf is a separate plugin package for PySCF integration. Not included by default.
fix
Install with `pip install openfermionpyscf` and import as `import openfermionpyscf`.
Upgrade
Version history
1.7.1latest on PyPI · released Jun 6, 2025
Audit
Dependencies
cirqoptionalUsed for quantum circuit simulation and interfaces
pyscfoptionalProvides molecular data and integrals
numpyrequiredNumerical computing backbone
Agent activity
29 hits · last 30 days
node
26
Amazon
1
OpenAI (training)
1
Resources