Strange error uploading Blink code to Wemos D1

Following is the error I am getting when uploading the blink code to a Wemos D1 mini for testing...

when searching for this error I found no leads whatsoever!


Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00002b30 (most recent call first):
exit status 3
C:\Program Files (x86)\Arduino\arduino-builder returned 3
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.
1 Like

This error indicates that a Python dependency is missing: the "encodings" module. I haven't seen this specific one before. Reports of a missing "serial" module used to come up regularly from the ESP8266 users, so you might do a search for that keyword instead.

as you rightly said it was showing a Python error earlier and now this...

uninstalled and installed entire Arudino IDE twice but still the same issue!

i am just too tired searching for a solution.

The ESP8266 Boards platform is installed to a different location from the Arduino IDE. So uninstalling the Arduino IDE has no effect on the ESP8266 installation and would not be expected to help with this problem.

If you want to try a complete uninstall of the ESP8266 platform, you can follow this procedure:

was checking your reply... and followed the link..

unfortunately that entire thread is for MacOS and I am on Windows with absolutely no knowledge of MacOS :slight_smile:

i do appreciate your help in sending me that thread. thank you!

now i am having a detailed error message below...

Arduino: 1.8.15 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\saint\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\saint\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\saint\Documents\Arduino\libraries -fqbn=esp8266:esp8266:nodemcuv2:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M2M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 -vid-pid=10C4_EA60 -ide-version=10815 -build-path C:\Users\saint\AppData\Local\Temp\arduino_build_196063 -warnings=none -build-cache C:\Users\saint\AppData\Local\Temp\arduino_cache_441687 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.python3.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.0-newlib4.0.0-gnu23-48f7b08 -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.0-newlib4.0.0-gnu23-48f7b08.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.0-newlib4.0.0-gnu23-48f7b08 -prefs=runtime.tools.mkspiffs.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.0-newlib4.0.0-gnu23-48f7b08 -prefs=runtime.tools.mkspiffs-3.0.0-newlib4.0.0-gnu23-48f7b08.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.0-newlib4.0.0-gnu23-48f7b08 -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\saint\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\saint\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\saint\Documents\Arduino\libraries -fqbn=esp8266:esp8266:nodemcuv2:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,eesz=4M2M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 -vid-pid=10C4_EA60 -ide-version=10815 -build-path C:\Users\saint\AppData\Local\Temp\arduino_build_196063 -warnings=none -build-cache C:\Users\saint\AppData\Local\Temp\arduino_cache_441687 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.python3.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.0-newlib4.0.0-gnu23-48f7b08 -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.0-newlib4.0.0-gnu23-48f7b08.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.0-newlib4.0.0-gnu23-48f7b08 -prefs=runtime.tools.mkspiffs.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.0-newlib4.0.0-gnu23-48f7b08 -prefs=runtime.tools.mkspiffs-3.0.0-newlib4.0.0-gnu23-48f7b08.path=C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\tools\mkspiffs\3.0.0-newlib4.0.0-gnu23-48f7b08 -verbose C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino

Using board 'nodemcuv2' from platform in folder: C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0

Using core 'esp8266' from platform in folder: C:\Users\saint\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0

Detecting libraries used...

"C:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.0-newlib4.0.0-gnu23-48f7b08/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0/tools/sdk/include" "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0/tools/sdk/lwip2/include" "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\saint\\AppData\\Local\\Temp\\arduino_build_196063/core" -c -w -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10815 -DARDUINO_ESP8266_NODEMCU_ESP12E -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_NODEMCU_ESP12E\"" -DLED_BUILTIN=2 -DFLASHMODE_DIO -DESP8266 "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0\\cores\\esp8266" "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0\\variants\\nodemcu" "C:\\Users\\saint\\AppData\\Local\\Temp\\arduino_build_196063\\sketch\\Blink.ino.cpp" -o nul

Generating function prototypes...

"C:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.0-newlib4.0.0-gnu23-48f7b08/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0/tools/sdk/include" "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0/tools/sdk/lwip2/include" "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\saint\\AppData\\Local\\Temp\\arduino_build_196063/core" -c -w -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -w -x c++ -E -CC -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10815 -DARDUINO_ESP8266_NODEMCU_ESP12E -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_NODEMCU_ESP12E\"" -DLED_BUILTIN=2 -DFLASHMODE_DIO -DESP8266 "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0\\cores\\esp8266" "-IC:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0\\variants\\nodemcu" "C:\\Users\\saint\\AppData\\Local\\Temp\\arduino_build_196063\\sketch\\Blink.ino.cpp" -o "C:\\Users\\saint\\AppData\\Local\\Temp\\arduino_build_196063\\preproc\\ctags_target_for_gcc_minus_e.cpp"

"C:\\Program Files (x86)\\Arduino\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\saint\\AppData\\Local\\Temp\\arduino_build_196063\\preproc\\ctags_target_for_gcc_minus_e.cpp"

Compiling sketch...

"C:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" "C:\\Users\\saint\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.0/tools/signing.py" --mode header --publickey "C:\\Program Files (x86)\\Arduino\\examples\\01.Basics\\Blink/public.key" --out "C:\\Users\\saint\\AppData\\Local\\Temp\\arduino_build_196063/core/Updater_Signing.h"

Fatal Python error: initfsencoding: unable to load the file system codec

ModuleNotFoundError: No module named 'encodings'



Current thread 0x000024b4 (most recent call first):

exit status 3

C:\Program Files (x86)\Arduino\arduino-builder returned 3

Error compiling for board NodeMCU 1.0 (ESP-12E Module).

I see now that they changed the article. The instructions were better before.

Here they are:

Be aware this will remove any boards you have installed via Boards Manager. They are easy enough to reinstall again though.

  1. Select File > Preferences from the Arduino IDE's menus.
  2. Click the link on the line following "More preferences can be edited directly in the file". This will open the Arduino15 (or similar name depending on your operating system) folder.
  3. Delete all files and folders under the Arduino15 folder except for the preferences.txt file. Please be very careful when deleting things from your computer. When in doubt, back up!

Now you will need to re-install the boards you just uninstalled:

  1. Select Tools > Board > Boards Manager from the Arduino IDE's menus.
  2. Wait for the update to finish.
  3. Reinstall the boards platforms (e.g., "esp8266 by ESP8266 Community") you need.
  4. Click the Close button

You can now try compiling again to see whether that procedure fixed the problem.

hi,

thank you very much for your efforts in helping me.

i tried as per the procedure you have explained...

unfortunately the error still persists...

i thank you again for your efforts to help me out :slight_smile:

still Arduino IDE is giving me the following error inspite of python being on the path of Win7 and Python gets executed from anywhere on the command prompt.

Error as follows:

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00001e7c (most recent call first):
exit status 3
C:\Program Files (x86)\Arduino\arduino-builder returned 3
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.

Looks like some helpful information here:

thank you for the link.

tried all options but Arduino IDE is still failing.

it keeps going to \AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3

and gives the following error

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000fec (most recent call first):
exit status 3
C:\Program Files (x86)\Arduino\arduino-builder returned 3
Error compiling for board LOLIN(WEMOS) D1 R2 & mini.

I have Python 3.8 installed on my Windows 7 machine and the path has been added to the environment variables.

Python can be executed from command prompt through any folder or directly without issues.

Only Arduino IDE is unable to use Python for itself. I also can't understand how to change the path of Python which is used by Arduino IDE when compiling.

It's set here:

That file is here on your computer:

C:\Users\<user name>\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\boards.txt

thank you for the update... just check as per your instructions and being a novice with Python I am not able to get it as you showed. maybe i am wrong and I completely agree to being wrong with no experience in working with that kind of detail.

attaching both the files which are on my pc.

pythonTXTfiles.zip (44.1 KB)

would be really helpful if you check the 2 files in the ZIP archive I have uploaded which happen to be at the following location...


C:\Users\<USERNAME>\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0

Oops, sorry about that. It is explained by this comment:

# These will be removed by the packager script when doing a JSON release

This information is automatically generated by the build system, and so removed when they create the release version of the ESP8266 boards platform you're using.

They only have it defined in the file I linked to facilitate beta testing.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.