Peoblem with bild

I try to build my project and then PlatformIO have next error :slight_smile:

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR (3.3.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:
 - framework-arduino-avr 5.1.0
 - toolchain-atmelavr 1.70300.191015 (7.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 9 compatible libraries
Scanning dependencies...
Dependency Graph
UnicodeEncodeError: 'charmap' codec can't encode characters in position 19-25: character maps to <undefined>:
  File "C:\Users\belka\.platformio\penv\Lib\site-packages\platformio\builder\main.py", line 177:
    env.SConscript("$BUILD_SCRIPT")
  File "C:\Users\belka\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py", line 591:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\belka\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\belka\.platformio\platforms\atmelavr\builder\main.py", line 162:
    target_elf = env.BuildProgram()
  File "C:\Users\belka\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "C:\Users\belka\.platformio\penv\Lib\site-packages\platformio\builder\tools\platformio.py", line 62:
    env.ProcessProjectDeps()
  File "C:\Users\belka\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "C:\Users\belka\.platformio\penv\Lib\site-packages\platformio\builder\tools\platformio.py", line 140:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "C:\Users\belka\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "C:\Users\belka\.platformio\penv\Lib\site-packages\platformio\builder\tools\piolib.py", line 1075:
    _print_deps_tree(project)
  File "C:\Users\belka\.platformio\penv\Lib\site-packages\platformio\builder\tools\piolib.py", line 1042:
    click.echo("%s|-- %s" % (margin, title), nl=False)
  File "c:\users\belka\.platformio\penv\lib\site-packages\click\utils.py", line 272:
    file.write(message)
  File "c:\users\belka\.platformio\penv\lib\site-packages\click\_compat.py", line 710:
    return _write(s)
  File "c:\users\belka\.platformio\penv\lib\site-packages\colorama\ansitowin32.py", line 41:
    self.__convertor.write(text)
  File "c:\users\belka\.platformio\penv\lib\site-packages\colorama\ansitowin32.py", line 164:
    self.wrapped.write(text)
  File "C:\Users\belka\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 1379:
    self.file.write(arg)
  File "C:\Users\belka\.platformio\python3\lib\encodings\cp1252.py", line 19:
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]

PlatformIO attempts to print the name of a library you are using and printing it causes an encoding error in conjuction with the CP1252 character map that your terminal seems to use.

What is the exact platformio.ini?

Do you use any libraries with non-ASCII characters?

Okay so it’s one of those libraries that have a title that makes PlatformIO crash.

Can you open a CLI and execute pio upgrade --dev? Does the error still ocurr after that?

If it does, please upload the whole failing project somewhere (e.g, github, googledrive) and post the link.

yes the problem persists. I will try to create a new project and build it.

I think it this library : “iarduino_GSM-master”.
and this is strange since it worked correctly in the past

Yes without doubt the non-ASCII characters come from there

this should be the cause of the crash. I’ll try and reproduce it locally.

1 Like

Yeah crashes for me too with the latest PlatformIO and Python 3.8.

Dependency Graph
UnicodeEncodeError: 'charmap' codec can't encode characters in position 19-25: character maps to <undefined>:
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\main.py", line 178:
    env.SConscript("$BUILD_SCRIPT")
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py", line 591:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Script\SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\Max\.platformio\platforms\atmelavr\builder\main.py", line 162:
    target_elf = env.BuildProgram()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\platformio.py", line 62:
    env.ProcessProjectDeps()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\platformio.py", line 141:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\piolib.py", line 1075:
    _print_deps_tree(project)
  File "C:\Users\Max\AppData\Local\Programs\Python\Python38\Lib\site-packages\platformio\builder\tools\piolib.py", line 1042:
    click.echo("%s|-- %s" % (margin, title), nl=False)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\utils.py", line 272:
    file.write(message)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\click\_compat.py", line 710:
    return _write(s)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\colorama\ansitowin32.py", line 41:
    self.__convertor.write(text)
  File "c:\users\max\appdata\local\programs\python\python38\lib\site-packages\colorama\ansitowin32.py", line 164:
    self.wrapped.write(text)
  File "C:\Users\Max\.platformio\packages\tool-scons\scons-local-4.1.0\SCons\Util.py", line 1379:
    self.file.write(arg)
  File "c:\users\max\appdata\local\programs\python\python38\lib\encodings\cp1252.py", line 19:
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
============================================== [FAILED] Took 1.29 seconds ==============================================

Part of this problem might be with Python and it may have better support for these encoding issues in higher versions.

You can temporarily solve the problem by changing the top line in the file lib\iarduino_GSM\library.properties from

name =			iarduino GSM (сотовая связь)

to just

name =			iarduino GSM

then it works in my console (cmd.exe)

Dependency Graph
|-- <iarduino GSM> 1.0.1
|   |-- <SoftwareSerial> 1.0
|-- <SoftwareSerial> 1.0
..
RAM:   [===       ]  30.7% (used 628 bytes from 2048 bytes)
Flash: [===       ]  29.7% (used 9572 bytes from 32256 bytes)
Building .pio\build\uno\firmware.hex
============================================= [SUCCESS] Took 2.48 seconds =============================================

It may also have something to do with the encoding that the terminal is set to. It should really be set to some unicode / UTF-8 setting and not CP1252 which does not seem to support cryllic character.

Are you using PlatformIO within VSCode and the default terminal there?

1 Like

An issue is opened at Cyrillic characters in library name causes UnicodeEncodeError · Issue #3971 · platformio/platformio-core · GitHub. Until then the above workaround is valid.

Thank you.
yes it helped me

I also discovered that turning on Beta: Use Unicode UTF-8 for worldwide language support solves the problem, too.