Troubleshooting Mbed Python Errors

If you encounter problems importing or building mbed projects, please try resetting your Python environment as shown on this page.

  1. Clear the Tools->Options->VisualGDB->General->Tools->Python Directory setting:See this page for more information about Python packages managed by VisualGDB.
  2. Delete the %LOCALAPPDATA%\VisualGDB\Python* directories.
  3. Restart Visual Studio and open the Mbed Project Wizard. When prompted to install Python, try installing the latest Python 3:This will install a version of Python that was tested with mbed scripts on our side, and it should work exactly as described in our mbed tutorials.
  4. If you still get an error while trying to clone an mbed repository, the selected mbed version might be referencing packages that are not available in the currently used Python version. If this happens, click the “Show output from failed command” link in the error message shown by VisualGDB:The log will contain output similar to the one shown below:
    Run "C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\python.exe "C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\lib\site-packages\mbed\" update mbed-os-6.9.0" in directory "c:\projects\temp\MbedProject2\mbed-os" on local computer
    Requirement already satisfied: colorama==0.3.9 in c:\users\virtual.sysprogs\appdata\local\visualgdb\python3\lib\site-packages (from -r c:\projects\temp\MbedProject2\mbed-os\requirements.txt (line 1)) (0.3.9)
    ERROR: Could not find a version that satisfies the requirement pywin32==224 (from versions: 225, 226, 227, 228, 300, 301, 302)
    ERROR: No matching distribution found for pywin32==224
    WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
    You should consider upgrading via the 'C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\python.exe -m pip install --upgrade pip' command.
    Command exited with code 1

    Take a note of the following parameters:

    1. Python executable used to run the command (in this example, C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\python.exe)
    2. The requirements file (in this example, c:\projects\temp\MbedProject2\mbed-os\requirements.txt)
    3. The exact package versions that failed (in this example, pywin32==224) and the available versions (in this example, 225..302)
  5. In order to make that mbed version work, you will need to adjust the requirements.txt file to reference the nearest package version provided by your Python distro. In this example, it would mean replacing the following line in requirements.txt:

    with the following one:

  6. Now you can re-run the “mbed update” command as shown in the log file, e.g.:
    cd c:\projects\temp\MbedProject2\mbed-os
    C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\python.exe "C:\Users\virtual.SYSPROGS\AppData\Local\VisualGDB\Python3\lib\site-packages\mbed\" update mbed-os-6.9.0
  7. Now you can import the manually patched mbed checkout into VisualGDB by selecting the “import” mode in the wizard: