Python API and data logging: mokucli issues


We’re using the Moku:Pro with the Python API (Moku Client Version 3.0.0, instrument fw=576) through Spyder and want to stream data from the datalogger via the get_stream_data() function. We have installed the mokucli (v2.1.0).

Upon first run, the software crashes and prints

Cannot find mokucli {cli_ver_major}.{cli_ver_minor}.{cli_ver_patch}, 
please download latest version of the CLI from

When I manually run the code from the of moku to check for the moku_cli_version the MOKU_CLI_PATH is empty, i.e. None.

Since the software mokucli is installed (I can run ‘mokucli --version’ in cmd.exe and get 2.1.0) I decided to set the path in the environment directly:

environ["MOKU_CLI_PATH"] = "C:\\Program Files\\Liquid Instruments\\Moku CLI"
MOKU_CLI_PATH = environ.get('MOKU_CLI_PATH')
    MOKU_CLI_PATH = str(Path(MOKU_CLI_PATH).expanduser())

However, now I get

Traceback (most recent call last):

  File "<ipython-input-6-3662c09a39cb>", line 1, in <module>

  File "<ipython-input-5-cfffdf067710>", line 30, in check_mokucli_version

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\", line 143, in __init__
    super(SubprocessPopen, self).__init__(*args, **kwargs)

  File "C:\ProgramData\Anaconda3\lib\", line 775, in __init__
    restore_signals, start_new_session)

  File "C:\ProgramData\Anaconda3\lib\", line 1178, in _execute_child

PermissionError: [WinError 5] Access is denied

I found that there were previous issues with the get_stream_data() mentioned before on the forum, but they were apparently resolved by downloading newer versions of the Moku software. However, since we already run the latest version, how could we fix our problem?


Hi dhwielens,

thanks for the detailed description of your Python API issues with Moku.

However, since we already run the latest version,

Ah, we have updated the firmware (notes here) to version 580 and also updated the Python client to v3.1.0.

Could you install the latest client app from : Windows & Mac App - Liquid Instruments
Then connect to your Moku to install firmware 580.

Also, the Python API should be v3.1.0. (‘moku’ on the command line should return v3.1.0); you may need to update that with pip install --upgrade moku

Once this is updated, please try your data streaming again,


Hi Paul,

Thanks for your reply. I’ve upgraded the python package to 3.1.0, upgraded the firmware to 580 and have mokucli 2.1.0 running. With all the upgrades, it still does not work by itself: the mokucli path is still not configured correctly so that the first error pops up again.

I then realized that perhaps I need to specify the full path to the executable, rather than that ‘MOKU_CLI_PATH’ is a folder (like a workspace directory).

Hence, the first few lines of the in the moku python package now become:

import pathlib
import tarfile
from hashlib import sha256
from os import environ
from pathlib import Path
from shutil import which
from subprocess import Popen, PIPE

from pkg_resources import get_distribution, resource_filename

from moku.exceptions import IncompatibleMokuException, MokuException
from moku.session import RequestSession
from moku.utilities import validate_range
from moku.version import compat_fw, cli_ver_major, cli_ver_minor, \

__version__ = get_distribution("moku").version
_data_path = environ.get('MOKU_DATA_PATH',
                         resource_filename("moku", 'data'))
MOKU_DATA_PATH = Path(_data_path).expanduser()

# MOKU_CLI_PATH = environ.get('MOKU_CLI_PATH', which("mokucli"))
#     MOKU_CLI_PATH = str(Path(MOKU_CLI_PATH).expanduser())

environ["MOKU_CLI_PATH"] = "C:\\Program Files\\Liquid Instruments\\Moku CLI\\mokucli.exe"
MOKU_CLI_PATH = environ.get('MOKU_CLI_PATH')
    MOKU_CLI_PATH = str(Path(MOKU_CLI_PATH).expanduser())

def check_mokucli_version():
        out, _ = Popen([MOKU_CLI_PATH, "--version"], stdout=PIPE,
        if out:
            result = out.decode("utf8").split('mokucli')
            if len(result) == 2:
                _ver = result[1].strip().split('.')
                if len(_ver) == 3:
                    _ma, _mi, _pa = map(int, _ver)
                    return _ma >= cli_ver_major and _mi >= cli_ver_minor and _pa >= cli_ver_patch
    raise Exception(
        f"Cannot find mokucli {cli_ver_major}.{cli_ver_minor}.{cli_ver_patch}, please download "
        f"latest version of the CLI from "
        " ")

(Here, I commented the original lines of code and added mine below it (lines 26-29). With these changes, I can run check_mokucli_version() which now returns True. Then, running datalogger.get_stream_data() returns data as expected.

Thus, it seems that the initialization in the API is unable to find the mokucli. Perhaps this can be addressed in a future API release?