{"id":8465,"library":"pyadi-iio","title":"pyadi-iio","description":"pyadi-iio is a Python abstraction module developed by Analog Devices for interfacing with their hardware devices that utilize Industrial I/O (IIO) drivers. It simplifies interaction with complex IIO interfaces by providing device-specific APIs, reducing boilerplate code for common operations like data acquisition and control. The current version is 0.0.20, and the library is actively maintained with ongoing development and contributions.","status":"active","version":"0.0.20","language":"en","source_language":"en","source_url":"https://github.com/analogdevicesinc/pyadi-iio","tags":["hardware","iio","analog-devices","sdr","data-acquisition","control","embedded"],"install":[{"cmd":"pip install pyadi-iio","lang":"bash","label":"Basic Installation"},{"cmd":"pip install pyadi-iio[jesd]","lang":"bash","label":"With JESD Debugging Support"}],"dependencies":[{"reason":"Core C library for IIO devices, must be installed separately (not via pip). Python bindings (pylibiio) are typically handled by pyadi-iio's pip install.","package":"libiio","optional":false},{"reason":"Python bindings for libiio. Automatically installed by pyadi-iio via pip since libiio v0.21.","package":"pylibiio","optional":false},{"reason":"Required for numerical operations and data handling.","package":"numpy","optional":false},{"reason":"Optional dependency for JESD204 debugging and control.","package":"paramiko","optional":true}],"imports":[{"symbol":"adi","correct":"import adi"}],"quickstart":{"code":"import adi\nimport os\n\n# Replace with your device's actual IP address or leave empty for local/USB detection\n# Ensure the target hardware is powered on and configured for network/USB communication\n# For network connection, the IP address should be accessible from the host.\n# Example: 'ip:192.168.2.1' for Ethernet, 'usb:1.24.5' for specific USB device\ndevice_uri = os.environ.get('ADIIO_URI', 'ip:192.168.2.1') \n\ntry:\n    # Create a device interface for a supported device, e.g., AD9361\n    sdr = adi.ad9361(uri=device_uri)\n\n    # Example: Print RX LO Frequency\n    print(f\"RX LO Frequency: {sdr.rx_lo}\")\n\n    # Example: Capture and print some RX data (ensure device is transmitting/receiving)\n    # This part assumes the device is configured and streaming data.\n    # In a real scenario, you'd configure sample rates, gains, etc. before reading.\n    sdr.rx_buffer_size = 2**12  # Set buffer size\n    data = sdr.rx()\n    print(f\"Captured {len(data)} RX samples.\")\n    # print(f\"First 10 RX samples: {data[:10]}\") # Uncomment to see sample values\n\nexcept Exception as e:\n    print(f\"Could not connect to or interact with device at {device_uri}: {e}\")\n    print(\"Please ensure libiio is installed and the device is accessible. \"\n          \"Refer to pyadi-iio documentation for device-specific setup.\")\n","lang":"python","description":"Initializes a connection to an Analog Devices IIO device, typically an SDR like AD9361, using its URI (IP address for network connection). It then demonstrates reading a device property and capturing a block of RX data. The `ADIIO_URI` environment variable can be used to specify the device's address, otherwise a default IP is attempted. This requires the `libiio` C library to be installed and the hardware device to be reachable."},"warnings":[{"fix":"Refer to the Analog Devices libiio GitHub repository for platform-specific installation instructions (e.g., apt-get on Linux, Windows installer). For Linux, building from source often requires the `-DPYTHON_BINDINGS=ON` CMake flag.","message":"The `libiio` C library is a fundamental prerequisite and must be installed separately on your operating system; it is not installed by `pip install pyadi-iio`. While `pylibiio` (Python bindings) is automatically installed, the underlying C library is crucial for functionality.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Set the `PYTHONPATH` environment variable to include the directory where `pylibiio` is installed (e.g., `export PYTHONPATH=$PYTHONPATH:/usr/lib/python{PYTHON VERSION}/site-packages`). Alternatively, install virtual environments with `--system-site-packages`.","message":"On Linux, if `libiio`'s Python bindings (pylibiio) are installed from source or in non-standard locations, the Python interpreter might not find them, leading to import errors even if `pyadi-iio` is installed. This often happens within virtual environments.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Check the device's specific API documentation or the `pyadi-iio` GitHub issues for the correct attribute names or methods to access these properties. Upgrading to a newer version may also resolve the issue if a fix has been implemented.","message":"Accessing certain read-only properties (e.g., `rx_sample_rate`, `dac_frequency`) for multi-channel/multi-chip devices like QuadMxFE in `pyadi-iio` v0.0.19 and possibly other versions can result in a `KeyError`. This indicates internal attribute naming changes or inconsistencies.","severity":"breaking","affected_versions":"0.0.19 (QuadMxFE)"},{"fix":"Consult the device-specific documentation or source code for the correct methods to enable/disable channels (e.g., by specifying `rx_enabled_channels = [0]` for channel 0) and to set individual gains. Direct attribute manipulation using `_ctrl.debug_attrs` might be necessary for advanced configurations.","message":"When working with devices that have multiple channels (e.g., for RX or TX), controlling individual channel states (enable/disable) or setting specific gains for each channel might not be intuitive or directly supported by simple list assignments, leading to errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"On Windows, try reinstalling `pylibiio` specifically using `pip install pylibiio` (or from `conda-forge` if using Anaconda). Also, ensure the `libiio` Windows driver (an executable installer from Analog Devices GitHub releases) is correctly installed.","cause":"This error often occurs on Windows systems when the underlying `pylibiio` library (Python bindings for `libiio`) is not correctly installed or linked, especially when using Anaconda environments. It indicates that a required library component or path is `None`.","error":"TypeError: argument of type 'NoneType' is not iterable"},{"fix":"Verify that the `libiio` command-line tools (like `iio_info` or `iio_readdev`) can successfully communicate with the device. Check hardware connections, device tree overlays (for Linux), and ensure the device URI in your Python code is correct. For specific boards like AD7124, ensure required GPIO pins (e.g., DOUT/RDY) are correctly connected.","cause":"This typically means there's a communication problem with the hardware device. Common causes include incorrect device overlays/drivers (especially on embedded Linux like Raspberry Pi), physical wiring issues (e.g., SPI connections), or the device not being correctly initialized or detected by `libiio`.","error":"IOError or I/O Error when reading data from device"},{"fix":"Ensure `pyadi-iio` is installed in your active Python environment using `pip install pyadi-iio`. If using virtual environments, activate the correct environment before running your script. Verify Python version compatibility (requires Python >= 3.8).","cause":"The `pyadi-iio` package or its main module alias `adi` is not found in the Python environment, indicating an installation issue or an incorrect virtual environment activation.","error":"ModuleNotFoundError: No module named 'adi'"}]}