Registry / testing / pyvisa-sim

pyvisa-sim

JSON →
library0.7.1pypypi✓ verified 89d ago

PyVISA-sim is a Python library that provides a simulated backend for PyVISA, allowing users to develop and test instrument control applications without needing physical hardware. It supports common resource types like TCPIP, GPIB, RS232, and USB, mimicking their behavior. The current version is 0.7.1, released on 2024-05-13, and it follows a regular, active release cadence.

pip install pyvisa-sim
INSTALL
IMPORT
SIG · PYVISA-SIM
P
pyvisa-sim
testingpythonv0.7.1
Install
2.0s avg
Import
493ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.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
py 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.514s · 22.4MB
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 2.0s · import 0.473s · 24MB
21MB installed
● package 21MB
Code
Verified usage

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

ResourceManager
✓ import pyvisa; rm = pyvisa.ResourceManager('@sim')
Users typically interact with `pyvisa-sim` by specifying the `@sim` backend string to `pyvisa.ResourceManager`, rather than importing symbols directly from `pyvisa_sim`.

This quickstart demonstrates how to initialize PyVISA with the simulated backend, list available simulated resources, open a default simulated USB instrument, perform basic SCPI write and read operations, and properly close the instrument and resource manager.

import pyvisa # Create a resource manager that uses the simulated backend # The '@sim' string tells PyVISA to load pyvisa-sim as the backend rm = pyvisa.ResourceManager('@sim') # List available simulated resources (pyvisa-sim comes with some defaults) print("Available resources:", rm.list_resources()) # Open a simulated instrument resource # This instrument is defined within pyvisa-sim's default simulation try: instrument = rm.open_resource('USB::0x1000::0x2000::0x3000::INSTR') # Basic SCPI commands print("Writing '*IDN?'...") instrument.write('*IDN?') idn = instrument.read() print("Read IDN:", idn) # Example of a command that changes state (simulation only) instrument.write('MEASURE:VOLTAGE:DC?') voltage = instrument.read() print("Simulated DC Voltage:", voltage) # Close the instrument instrument.close() print("Instrument closed.") except Exception as e: print(f"An error occurred: {e}") finally: # Close the resource manager rm.close() print("Resource manager closed.")
Debug
Known issues
gotcha`pyvisa-sim` requires `pyvisa` to be installed and used. It's a backend plugin, not a standalone library. Trying to use it without `pyvisa` will lead to errors.
fix
Ensure `pyvisa` is installed: `pip install pyvisa`.
affects: All versions
gotchaTo engage the simulation, you MUST explicitly use the `@sim` backend string (e.g., `pyvisa.ResourceManager('@sim')`). If omitted or misspelled, PyVISA will attempt to connect to actual hardware or the default backend, leading to unexpected behavior or connection errors.
fix
Always initialize your resource manager with `rm = pyvisa.ResourceManager('@sim')`.
affects: All versions
gotcha`pyvisa-sim` provides *simulated* responses. While it aims to mimic real instruments, complex or highly specific instrument behaviors may not be perfectly replicated without further configuration (e.g., custom YAML files or programmatic resource registration).
fix
For specific instrument models or complex scenarios, consult the `pyvisa-sim` documentation on how to customize or extend the simulated instrument behavior.
affects: All versions
Errors
Common errors & fixes
pyvisa.errors.VisaIOError: VI_ERROR_RSRC_NFOUND (resource not found)
The specified resource string (e.g., 'USB::0x1000::0x2000::0x3000::INSTR') does not exist in the currently loaded simulation. `pyvisa-sim` provides default resources, but custom ones need to be configured.
fix
Check `rm.list_resources()` to see available resources. For custom resources, configure `pyvisa-sim` with a custom YAML file or by registering resources programmatically.
ValueError: No backend available for the given session. Make sure you have the 'pyvisa-sim' package installed and are using the '@sim' backend alias.
`pyvisa-sim` is not installed, or the `@sim` backend string is misspelled/missing when initializing `ResourceManager`.
fix
Install `pyvisa-sim` using `pip install pyvisa-sim`. Verify the backend string is exactly `'@sim'` when creating the resource manager.
AttributeError: module 'pyvisa_sim' has no attribute 'SomeClass'
Attempting to import or use a class directly from the `pyvisa_sim` module that is not intended for direct user interaction or does not exist.
fix
`pyvisa-sim` acts as a backend for `pyvisa`. Most user interaction should be via `pyvisa.ResourceManager('@sim')` and standard PyVISA methods, not by importing symbols directly from `pyvisa_sim`.
Upgrade
Version history
0.7.1latest on PyPI · released Sep 4, 2025
Audit
Dependencies
pyvisarequired`pyvisa-sim` acts as a backend for `pyvisa` and requires it for functionality.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
pyvisa-sim — pip install pyvisa-sim · libregistry