-1

I am using Arduino IDE 2.3.4 to program a XIAO nRF52840 Sense. I added the board using the instructions on the official getting started page.

After installing the board in Arduino IDE, I open up the blinky example. When I press Ctrl+U, a long sequence of compiles appear in the console output but it ends on this error. The error persists even if I restart the IDE. I have checked the file in this location, it has this exact code in line 5.

Some search on google tells me this is a type annotation colon but no clue on why this error appears or how to solve it.

Here is the error text:

python "C:\\Users\\my user name\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\nrf52\\1.1.10/tools/uf2conv/uf2_wrap.py" "C:\\Users\\my user name\\AppData\\Local\\Arduino15\\packages\\Seeeduino\\hardware\\nrf52\\1.1.10/tools/uf2conv/uf2conv.py" Seeed_XIAO_nRF52840_Sense "C:\\Users\\my user name\\AppData\\Local\\arduino\\sketches\\016CEDE8C21B2FFF8F3C8148DE9D6C52" "C:\\Users\\my user name\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2025512-14296-4v0mzk.j8o4i\\blinky" blinky.ino
  File "C:\Users\my user name\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.10/tools/uf2conv/uf2_wrap.py", line 5
    def main(uf2_file: str, board_id: str, build_path: str, output_path: str, project_name: str):
                     ^
SyntaxError: invalid syntax

Using library Adafruit TinyUSB Library at version 1.7.0 in folder: C:\Users\my user name\AppData\Local\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.10\libraries\Adafruit_TinyUSB_Arduino exit status 1

Compilation error: exit status 1

Question: How do I solve this Syntax Error?


enter image description here

paki eng
  • 99
  • 4

1 Answers1

1

Update your system installed Python interpreter.
Consider removing an extra versions you have.
Make sure the updated one is the one found in your path.


Some (not all) tool packages for Arduino bundle a copy of the Python interpreter and use that where needed. The current version of the Seeedstudio tools is not one of these. It depends on a compatible system-installed version of Python being in your path. For comparison here's the Earle Philhower RP2040 board package referring to its own bundled copy of python within its tool directories.

Some search on google tells me this is a type annotation colon but no clue on why this error appears or how to solve it.

This type hint syntax was not accepted by the Python interpreter prior to version 3.5. You apparently have an old interpreter, otherwise you would have seen a different error about not being able to execute python altogether. At time of writing the current version is 3.13.x and should work fine.


Another option: modifying platform.txt

In a comment the original poster mentioned that python is resolving to python2 and that changing this may break other installed software for them. For this sort of you can try modifying the platform.txt file in boards package under arduino15 directory. It may not be the best option, but it is something you can do with modifications to the Arduino specific software involved.

For the Seeeduino version 1.1.10 boards package platfrom.txt can be found at <arduino15>/packages/Seeeduino/hardware/nrf52/1.1.10/platform.txt.

You would need to modify the recipe.objcopy.uf2.pattern=python ... line. If python3 resolves to a new enough python3 interpreter, then adding a 3 in that line is enough. E.g.:

recipe.objcopy.uf2.pattern=python3 "{runtime.platform.path}/tools/uf2conv/uf2_wrap.py" "{runtime.platform.path}/tools/uf2conv/uf2conv.py" "{build.board}" "{build.path}" "{build.source.path}" "{build.project_name}"

Otherwise you may need to resort to specifying a absolute path to a python3 interpreter, or to your own script to set up the correct environment, etc. The same sorts of techniques can be applied to any other tools that are specified in the boards packages. Keep in mind that when you update or reinstall the Seeeduino package it will undo this change.

timemage
  • 5,639
  • 1
  • 14
  • 25