Arm Mbed OS support forum

CLI2 windows setup: mbed-tools not found

Hi.

I followed setup guide for CLI2 using a virtual environment (venv), but after having installed mbed-tools using pip, I cannot find mbed-tools command. Should it be inside site-packages/workspace_tools directory?

Thanks!

Hello Lorenzo,

Try to run the following command:

pip show -f mbed-tools

If that doesn’t work then try:

pip3 show -f mbed-tools

The line ending with /mbed-tools in the results should tell you the path to the mbed-tools command.

Hi Zoltan.

Thanks. I succeeded in locating mbed-tools.exe and discovered it was installed inside virtual environment “Scripts” folder.

Now I can launch it, but I get:

(venv-cli2) PS C:\Progetti\Lab\mBed> mbed-tools -h
Traceback (most recent call last):
  File "C:\Users\maior\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\maior\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Progetti\Lab\mBed\venv-cli2\Scripts\mbed-tools.exe\__main__.py", line 4, in <module>
  File "C:\Progetti\Lab\mBed\venv-cli2\lib\site-packages\mbed_tools\cli.py", line 14, in <module>
    from mbed_build.mbed_tools import cli as mbed_build_export_cli
ImportError: cannot import name 'cli' from 'mbed_build.mbed_tools' (C:\Progetti\Lab\mBed\venv-cli2\lib\site-packages\mbed_build\mbed_tools.py)

Any idea?

Thanks!

I would try to add that path to the PATH variable:

Add to the PATH on Windows 10

  1. Open the Start Search, type in “env”, and choose “Edit the system environment variables”:
  2. Click the “Environment Variables…” button.
  3. Under the “System Variables” section (the lower half), find the row with “Path” in the first column, and click edit.

If I correctly followed your suggestion (please see powershell “session” below) it doesn’t work :frowning:

(venv-cli2) PS C:\Progetti\Lab\mBed> mbed-tools
Traceback (most recent call last):
  File "C:\Users\maior\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\maior\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Progetti\Lab\mBed\venv-cli2\Scripts\mbed-tools.exe\__main__.py", line 4, in <module>
  File "C:\Progetti\Lab\mBed\venv-cli2\lib\site-packages\mbed_tools\cli.py", line 14, in <module>
    from mbed_build.mbed_tools import cli as mbed_build_export_cli
ImportError: cannot import name 'cli' from 'mbed_build.mbed_tools' (C:\Progetti\Lab\mBed\venv-cli2\lib\site-packages\mbed_build\mbed_tools.py)
(venv-cli2) PS C:\Progetti\Lab\mBed> $env:Path += ";C:\Progetti\Lab\mBed\venv-cli2\lib\site-packages\mbed_build"
(venv-cli2) PS C:\Progetti\Lab\mBed> mbed-tools
Traceback (most recent call last):
  File "C:\Users\maior\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\maior\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Progetti\Lab\mBed\venv-cli2\Scripts\mbed-tools.exe\__main__.py", line 4, in <module>
  File "C:\Progetti\Lab\mBed\venv-cli2\lib\site-packages\mbed_tools\cli.py", line 14, in <module>
    from mbed_build.mbed_tools import cli as mbed_build_export_cli
ImportError: cannot import name 'cli' from 'mbed_build.mbed_tools' (C:\Progetti\Lab\mBed\venv-cli2\lib\site-packages\mbed_build\mbed_tools.py)

Make sure Python 3 is the default version on your system. To verify, run the python command. It should return something like:

Python 3.6.9 (default, ...

I actually use a virtual environment, whose python interpreter says:

Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32

I’m sorry but I ran out of ideas. Maybe someone else can give you a tip.

Updating to latest (pre) version solved the issue.

Thanks!