Install & Compatibility
Where this runs
tested against v8.5.2 · 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
muslpy 3.10–3.920 runs
build_error
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 4.0s · import 0.298s · 172MB
154MB installed
● package 154MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
openmm.app
✓ from openmm.app import *
✗ import simtk.openmm.app as app
The 'simtk' prefix was deprecated and removed in OpenMM 8.x. Direct import from 'openmm.app' is the correct modern approach.
openmm.unit
✓ from openmm.unit import *
✗ import simtk.unit as unit
The 'simtk' prefix was deprecated and removed in OpenMM 8.x. Direct import from 'openmm.unit' is the correct modern approach.
This quickstart demonstrates a basic molecular dynamics simulation using OpenMM. It loads a PDB file, applies a force field to create a system, sets up a Langevin integrator, performs energy minimization, and then runs a short simulation, saving trajectory and state data. A `protein.pdb` file is required in the execution directory for this example to run.
import openmm.app as app
import openmm as mm
import openmm.unit as unit
# This example assumes a 'protein.pdb' file exists in the same directory.
# A minimal PDB can be generated or downloaded, e.g., from RCSB PDB (e.g., 1AKI).
# For a real simulation, ensure your PDB is properly prepared (e.g., with PDBFixer).
try:
pdb = app.PDBFile('protein.pdb')
except FileNotFoundError:
print("Error: 'protein.pdb' not found. Please provide a PDB file for the quickstart.")
exit()
# Create a force field for the system
forcefield = app.ForceField('amber14-all.xml', 'amber14/tip3pfb.xml')
# Create a system from the PDB topology and force field
system = forcefield.createSystem(pdb.topology,
nonbondedMethod=app.PME,
nonbondedCutoff=1.0*unit.nanometers,
constraints=app.HBonds)
# Create an integrator for advancing the simulation
integrator = mm.LangevinMiddleIntegrator(300*unit.kelvin, 1/unit.picosecond, 0.004*unit.picoseconds)
# Create a simulation object
simulation = app.Simulation(pdb.topology, system, integrator)
simulation.context.setPositions(pdb.positions)
# Minimize energy to relieve bad contacts
print('Minimizing energy...')
simulation.minimizeEnergy()
print(f'Potential energy after minimization: {simulation.context.getState(getEnergy=True).getPotentialEnergy()}')
# Add reporters for output
simulation.reporters.append(app.PDBReporter('output.pdb', 1000))
simulation.reporters.append(app.StateDataReporter('data.csv', 1000, step=True, potentialEnergy=True, temperature=True, separator=','))
# Run the simulation
print('Running simulation...')
simulation.step(10000) # Run 10,000 steps
print('Simulation complete. Output saved to output.pdb and data.csv')
Errors
Common errors & fixes
ImportError: DLL load failed while importing _openmm: The specified module could not be found.
This error commonly occurs on Windows when OpenMM's C++ libraries or their dependencies are not correctly found by the Python environment, often due to issues with PATH or a corrupted `conda` environment.
fixTry creating a new, clean `conda` environment and reinstalling OpenMM: `conda create -c conda-forge --name openmm_env python=3.9 openmm` then `conda activate openmm_env`. Also ensure system PATH includes necessary OpenMM library directories if installed from standalone installers.
OpenMMException: Expected a Quantity object but got a float/int.
A numerical value (float or int) was provided where OpenMM expected a `openmm.unit.Quantity` object with a specified unit.
fixAppend a unit from `openmm.unit` to the numerical value, e.g., change `300` to `300*unit.kelvin` or `1.0` to `1.0*unit.nanometers`.
OpenMMException: Platform 'CUDA' is not available.
The OpenMM `CUDA` platform could not be initialized. This typically means NVIDIA CUDA Toolkit or compatible drivers are not installed, not correctly configured, or not visible to OpenMM.
fixInstall the latest NVIDIA GPU drivers and the CUDA Toolkit appropriate for your system. Verify installation with `python -m openmm.testInstallation`.
Upgrade
Version history
8.5.2latest on PyPI · released Jun 8, 2026
Audit
Dependencies
numpyrequiredCommonly used for numerical operations and data handling in conjunction with OpenMM.