PyMeasure

raw JSON →
0.15.0 verified Fri May 01 auth: no python

PyMeasure is a scientific measurement library for Python that provides instrument communication, experiment management, and live-plotting. As of version 0.15.0 (January 2025), it supports Python >=3.8 and has moved to pyproject.toml. The library is actively maintained with frequent releases featuring new instrument drivers and improvements.

pip install pymeasure
error ModuleNotFoundError: No module named 'pymeasure.instruments'
cause PyMeasure is not installed or installed incorrectly (e.g., missing subpackage).
fix
Ensure correct installation: pip install pymeasure (or pip install --upgrade pymeasure). Also check for pip conflicts (e.g., multiple environments).
error AttributeError: module 'pymeasure' has no attribute 'instruments'
cause The top-level pymeasure package does not export subpackages; you must import from the correct subpackage.
fix
Use from pymeasure.instruments import Instrument instead of from pymeasure import instruments.
error VisaIOError: VI_ERROR_TMO (-1073807339) – Timeout expired before operation completed
cause The instrument did not respond within the default timeout. This often happens with slow instruments or incorrect connection settings.
fix
Increase the timeout: instrument = Keithley2400("GPIB0::24::INSTR", timeout=5000) or check the physical connection and address.
deprecated The FSL class from `pymeasure.instruments.rohdeschwarz.fsl` is deprecated. Use `pymeasure.instruments.rohdeschwarz.fsseries` instead.
fix Replace `from pymeasure.instruments.rohdeschwarz.fsl import FSL` with `from pymeasure.instruments.rohdeschwarz.fsseries import FSL`
deprecated Attocube ANC300: `stepu` and `stepd` properties are deprecated.
fix Use the new `move_raw` method instead.
breaking In version 0.13.0, support for Python 3.7 was dropped. Python 3.8+ required.
fix Upgrade Python to 3.8 or later. For older Python, use pymeasure<0.13.0.
gotcha Instrument initialization often requires a connection string. Using an incorrect string (e.g., missing protocol prefix) can cause cryptic VISA errors.
fix Use proper connection strings like 'GPIB0::24::INSTR', 'ASRL/dev/ttyUSB0::INSTR', or 'TCPIP0::192.168.1.1::inst0::INSTR'.
pip install pymeasure[all]

Quickstart: import PyMeasure, create an instrument, define a procedure, and run it.

import pymeasure
from pymeasure.instruments.keithley import Keithley2400
from pymeasure.experiment import Procedure, Results
from pymeasure.display import ManagedWindow

# Check version
print(pymeasure.__version__)

# Example: create a Keithley 2400 instrument (simulated if no hardware)
try:
    keithley = Keithley2400("GPIB0::24::INSTR")
    print(keithley.id)
except Exception as e:
    print(f"Could not connect: {e}")

# Define a simple procedure
class MyProcedure(Procedure):
    def execute(self):
        import time
        for i in range(5):
            self.emit('data', {'i': i})
            time.sleep(0.1)

# Create and run procedure
results = Results(MyProcedure(), 'test.csv')
print('Procedure created. See framework documentation for full GUI usage.')