Unable to use latest Arduino IDE with nRF52840

OS: MacOS 13.3
IDE: Arduino 2.0.4
Board: Seeed XIAO nRF52840

I’ve got the following error while trying to compile the sketch(any):

Traceback (most recent call last):
  File "__main__.py", line 317, in <module>
  File "click/core.py", line 1134, in __call__
  File "click/core.py", line 1040, in main
  File "click/_unicodefun.py", line 100, in _verify_python_env
RuntimeError: Click will abort further execution because Python was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/unicode-support/ for mitigation steps.

This system lists some UTF-8 supporting locales that you can pick from. The following suitable locales were discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8
[28792] Failed to execute script __main__

exit status 1

Compilation error: exit status 1

Any idea how to solve this?

This error occurs because the default encoding for your Python environment is set to ASCII, which can cause issues when working with non-ASCII characters.

To fix this error, you need to set your default Python encoding to UTF-8. Here are the steps to do it:

Open the terminal on your Mac.

Run the command below to open your bash profile:

bash
Copy code
nano ~/.bash_profile
Add the following line at the end of the file:
arduino
Copy code
export LC_ALL=en_US.UTF-8
Press Control + X to exit nano and save the changes.

Close the terminal and reopen it.

Try compiling your sketch again.

This should solve the error you’re experiencing.
Greeting,
Rachel Gomez

1 Like

Which example did you use to run it?
You first check to see if you have successfully added the libraries needed for the example in arduino.
I hope I can help you.

In my case it didn’t help.
MacBook Pro
Apple M1
macOS: 13.4.1 (22F82)

I get this (when verifying Blink.ino from examples)

Traceback (most recent call last):
  File "__main__.py", line 317, in <module>
  File "click/core.py", line 1134, in __call__
  File "click/core.py", line 1040, in main
  File "click/_unicodefun.py", line 100, in _verify_python_env
RuntimeError: Click will abort further execution because Python was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/unicode-support/ for mitigation steps.

This system lists some UTF-8 supporting locales that you can pick from. The following suitable locales were discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8
[55488] Failed to execute script __main__

exit status 1

Compilation error: exit status 1

my bash environment:

23-07-12 22:14 ~ % cat .zshrc
echo .zshrc
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
alias rustdoc="rustup doc --toolchain=stable-x86_64-apple-darwin"
PROMPT='%F{cyan}%D %T%f %~ %# '

23-07-12 22:14 ~ % cat .zprofile
echo .zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
eval "$(pyenv init --path)"
alias ll='ls -al'
export LC_ALL=en_US.UTF-8

23-07-12 22:15 ~ % env | grep LC
LC_TERMINAL_VERSION=3.4.19
LC_CTYPE=UTF-8
LC_TERMINAL=iTerm2
LC_ALL=en_US.UTF-8
23-07-12 22:15 ~ %

BN: Seeed XIAO nRF52840 Sense
VID: 0x2886
PID: 0x8045
SN: A7EBF92E645A90C7

Version: 2.1.1
Date: 2023-07-03T07:51:40.946Z (1 week ago)
CLI Version: 0.32.3
Copyright © 2023 Arduino SA

23-07-12 22:25 ~ % python --version
Python 3.11.1

and the problem in the same environment doesn’t occur for XIAO ESP32 C3

Yes, I’m also having the same error.

BN: Seeed XIAO nRF52840 Sense
VID: 0x2886
PID: 0x8045
SN: 26559BD3B5FC113E

Version: 2.0.4
Date: 2023-02-27T14:25:47.115Z
CLI Version: 0.31.0
Copyright © 2023 Arduino SA

MacBook-Air ~ % python --version
Python 3.11.4

We need solution to this problem.

Hi everyone :slight_smile:


I just tested that Arduino IDE 2.1.0 can be run and used together. You can try it in the following ways:

  1. Reinstall the arduino ide and run it again
  2. Check the error message ‘This system lists some UTF-8 supporting locales that you can pick from.’ You know it’s a coding problem so you need to do a few steps (it worked on my computer)
    Add the following two lines to.bash_profile – set the encoding:
    ❀open .bash_profile
    ❀export LC_ALL=en_US.utf-8
    export LANG=en_US.utf-8
    ❀To have the Settings take effect, run source.bash_profile,
    ❀After exiting PyCharm, open the project again

If you solve your problem, you might give a like and let more people see it
Jostar

Hi, thanks for your advise - unfortunately it didn’t help:
exports

If you see something like this error:

Traceback (most recent call last): ... RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Either switch to Python 2 or consult http://click.pocoo.org/python3/ for mitigation steps.

You’re dealing with an environment where Python 3 thinks you’re limited to ASCII data. The solutions to these problems vary depending on the locale of the running computer.

For example, if you have a German Linux computer, you can solve this problem by exporting your locale to de_DE.utf-8:

export LC_ALL=de_DE.utf-8 export LANG=de_DE.utf-8

If you are using a US machine, en_US.utf-8 is the preferred encoding. On some newer Linux systems, you can also try using C.UTF-8 as the locale:

export LC_ALL=C.UTF-8 export LANG=C.UTF-8
In short,You will need to change different encoding Settings depending on your computer.

As I wrote before - I’m running MacOS not Linux.
I also run have this:

23-07-23 12:50 ~ % env | grep LC_
LC_TERMINAL_VERSION=3.4.19
LC_CTYPE=UTF-8
LC_TERMINAL=iTerm2
LC_ALL=en_US.UTF-8
23-07-23 12:50 ~ % env | grep LANG
LANG=en_US.UTF-8

so I don’t understand why I cannot run the simplest test program:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

I also wrote before that:
the problem in the same environment doesn’t occur for XIAO ESP32 C3
see:

int led = D10;

void setup() {
  // initialize digital pin led as an output
  pinMode(led, OUTPUT);
}

void loop() {
  digitalWrite(led, HIGH);   // turn the LED on 
  delay(3000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off
  delay(3000);
}
Sketch uses 216252 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 15424 bytes (4%) of dynamic memory, leaving 312256 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.2.1
Serial port /dev/cu.usbmodem1101
Connecting...
Chip is ESP32-C3 (revision 4)
Features: Wi-Fi
Crystal is 40MHz
MAC: 64:e8:33:d9:86:4c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00003fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x00047fff...
Compressed 12944 bytes to 9310...
Writing at 0x00000000... (100 %)
Wrote 12944 bytes (9310 compressed) at 0x00000000 in 0.3 seconds (effective 335.1 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000... (100 %)
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 346.2 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 512.0 kbit/s)...
Hash of data verified.
Compressed 226224 bytes to 126949...
Writing at 0x00010000... (12 %)
Writing at 0x0001a7c0... (25 %)
Writing at 0x00021b71... (37 %)
Writing at 0x000279cd... (50 %)
Writing at 0x0002df6d... (62 %)
Writing at 0x00033c2f... (75 %)
Writing at 0x0003b915... (87 %)
Writing at 0x00042705... (100 %)
Wrote 226224 bytes (126949 compressed) at 0x00010000 in 3.0 seconds (effective 596.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

and in case of ES32C3 it works

Another question is:
why in case of XIAO nRF52840 Sense “click/core.py” is used and in case of XIAO ESP32C3: "esptool.py’

OK - I can see, that ESP32C3 is based on another MCU but still I don’t know how to deal with the error for XIAO nRF52840 Sense

Hi @gileyro, I’ve ended up with the same issue on my Mac. Did you find a solution?

Can you post your error message?

Hi, it’s the same

Library Adafruit nRFCrypto has been declared precompiled:
Using precompiled library in /Users/<user>/Library/Arduino15/packages/Seeeduino/hardware/nrf52/1.1.8/libraries/Adafruit_nRFCrypto/src/cortex-m4/fpv4-sp-d16-hard
Traceback (most recent call last):
  File "__main__.py", line 317, in <module>
  File "click/core.py", line 1134, in __call__
  File "click/core.py", line 1040, in main
  File "click/_unicodefun.py", line 100, in _verify_python_env
RuntimeError: Click will abort further execution because Python was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/unicode-support/ for mitigation steps.

This system lists some UTF-8 supporting locales that you can pick from. The following suitable locales were discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8
[35065] Failed to execute script __main__

exit status 1

Compilation error: exit status 1

BTW, I think I have “fixed” it.

  • Downloaded booth boards, “Seeed nRF52 Boards” and “Seeed nRF52 mbed-enabled Boards”
  • Then I have copied the the adafruit-nrfutil from /Users/<user>/Library/Arduino15/packages/Seeeduino/hardware/mbed/2.9.2/tools/adafruit-nrfutil/macos/adafruit-nrfutil to /Users/<user>/Library/Arduino15/packages/Seeeduino/hardware/nrf52/1.1.8/tools/adafruit-nrfutil/macos/adafruit-nrfutil
  • Then chmod -x the copied file

Now looks like it works fine

3 Likes

Good job! I’ll mark your reply as a solution!

1 Like

In case someone runs into the same issue. Ensure you select the Seeed nRF52 mbed-enabled Boards for the board in arduino instead of Seeed nRF52 Boards.