Metadata-Version: 2.5
Name: moku
Version: 4.4.0.0
Summary: Python scripting interface to the Liquid Instruments Moku hardware
Project-URL: Homepage, https://liquidinstruments.com
Project-URL: Documentation, https://apis.liquidinstruments.com
Project-URL: Issues, https://www.liquidinstruments.com/support/contact/
Author-email: Liquid Instruments <info@liquidinstruments.com>
License: MIT
License-File: LICENSE.txt
Keywords: equipment,lab,liquid instruments,measurement,moku,mokugo,mokupro,test
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.11
Requires-Dist: deprecated>=1.3.1
Requires-Dist: packaging>=20.0
Requires-Dist: pydantic>=2.10.6
Requires-Dist: requests<3.0,>=2.0
Requires-Dist: zeroconf>=0.47.0
Provides-Extra: neuralnetwork
Requires-Dist: numpy>=2.2; extra == 'neuralnetwork'
Requires-Dist: tensorflow>=2.21; extra == 'neuralnetwork'
Description-Content-Type: text/markdown

# Moku
A Python library for the command, control and monitoring of [Liquid Instruments Moku](https://www.liquidinstruments.com) Moku hardware.

Official documentation for this library is available on the [Moku API documentation](https://apis.liquidinstruments.com/api/) page, and includes more information on getting started, tutorials and examples.

# Getting Started

## 1. Requirements
- [Python](https://www.python.org) >= **3.11** installed
- Your Moku connected to the same network as your computer
- Internet access (once off to fetch data files)

### 2. Install the `mokucli` utility

`mokucli` is a separate command-line utility, required for device data management, discovery and data streaming. Download and install it from the [Moku Utilities](https://liquidinstruments.com/software/utilities/) page.

After installation, verify it works by listing the Moku devices on your network:

    mokucli list

### 3. Install the Python package

    pip install --upgrade moku

If you wish to build and train models for the Moku Neural Network instrument, install the optional machine learning dependencies:

    pip install "moku[neuralnetwork]"

### 4. Download instrument bitstreams

Before an instrument can be deployed, it must be present in your local cache. Download the set matching your device with:

    mokucli instrument download --ip <your-moku-ip>

This auto-detects the device's firmware version and downloads the matching bitstreams. If you don't have network access to your Moku at this time, you can specify the set by version instead

    mokucli instrument download 4.3.1

Find your device's version and IP address in the output of `mokucli list`, or in a compatible Moku App, available for Desktop and iPad.

### 5. Start scripting
You are now ready to control your Moku using Python! You can find example scripts in the **moku/examples/** folder of the installed package. Here is a basic example of how to connect to a Moku, deploy the Oscilloscope and fetch a single data trace. Open python and run the following code:

```python
from moku.instruments import Oscilloscope

# Connect by IP address, or by serial with Oscilloscope(serial=123)
i = Oscilloscope('192.168.###.###', force_connect=False)

try:
    # Span -1s to 1s, i.e. trigger point centred
    i.set_timebase(-1, 1)

    # Fetch one frame: a time series of voltage per channel
    data = i.get_data()
    print(data['ch1'], data['ch2'], data['time'])
except Exception as e:
    print(f'Exception occurred: {e}')
finally:
    i.relinquish_ownership()
```

# Debug Logging

The Moku library includes built-in logging support for debugging connection issues and monitoring API calls. By default, the library does not produce any log output. To enable debug logging:

```python
import moku.logging

# Enable debug logging to stderr
moku.logging.enable_debug_logging()

# Your Moku code here - all operations will be logged
from moku.instruments import Oscilloscope

osc = Oscilloscope('192.168.###.###')

# Disable logging when done
moku.logging.disable_debug_logging()
```

For temporary debugging, use the context manager:

```python
import moku.logging

with moku.logging.LoggingContext():
    # Debug logging only enabled within this block
    osc = Oscilloscope('192.168.###.###')
    # ...
```

# Troubleshooting

#### ModuleNotFoundError: No module named 'moku'

A system often has several Python installations. Make sure you install into the same interpreter you run:

- Install with `python -m pip install --upgrade moku` so it targets the interpreter you invoke as `python`.
- If you use a virtualenv or conda environment, activate it first, then confirm the package is present with `pip list`.
- You may need to add your Python scripts directory to `PATH`. This varies by operating system and Python version, for example:

      export PATH=$PATH:/home/user/.local/bin

Verify the install with:

    python -c "import moku"

No error indicates a successful install.

## Issue Tracking

Please report issues at https://www.liquidinstruments.com/support/contact/
