Esp8266, esp-01 Fatal Python error

Hello. I'm trying to upload a blank sketch to my Esp8266 esp-01 using the Arduino IDE 2.0.4 and I get the following error:

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

Current thread 0x00003578 (most recent call first):

exit status 3

Compilation error: exit status 3`

I would like to mention that I have tried to reinstall the IDE (deleting all the folders after uninstall) reinstall the boards esp8266 by esp8266 Community (a strange thing, after reintall, in the "Additional boards manager URLs" I still have the http://arduino.esp8266.com/stable/package_esp8266com_index.json address). Also I'm using a USB adapter dedicated for the esp-01 board (CH340-USB-To-ESP8266-ESP-01). And also I'm using Windows 7.

Can anyone guide me on how to resolve the error?

what did you tried before? i mean, is it your first attempt in MCU world?

I had installed an older version of the IDE 1.xx and with that I got a similar error. I don't now what the MCU abbreviation stands for :pensive:

That error normally relates to an environment variable issue with the Python installation. I would expect the IDE install procedure to take care of all that but maybe it doesn't.
Someone like @ptillisch may be able to help.

Hi @georgepa. I'm going to ask you to post some additional information that might help us to identify the problem.


:exclamation: NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.


Please do this:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Check the box next to "Show verbose output during: ☐ compilation".
  3. Click the OK button.
  4. Select Sketch > Verify/Compile from the Arduino IDE menus.
  5. Wait for the compilation to fail.
  6. You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the COPY ERROR MESSAGES button on that notification.
  7. Open a forum reply here by clicking the Reply button.
  8. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code tags icon on toolbar
  9. Press Ctrl+V.
    This will paste the compilation output into the code block.
  10. Move the cursor outside of the code tags before you add any additional text to your reply.
  11. Click the Reply button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the Reply button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:
    Upload icon on toolbar
  6. Select the .txt file you saved.
  7. Click the Open button.
  8. Click the Reply button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

Here is the error:

Using board 'generic' from platform in folder: C:\Users\George\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2
Using core 'esp8266' from platform in folder: C:\Users\George\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2
"C:\\Users\\George\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\python3\\3.7.2-post1/python3" -I "C:\\Users\\George\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.1.2/tools/mkbuildoptglobals.py" "C:\\Users\\George\\AppData\\Local\\Programs\\arduino-ide\\resources\\app\\node_modules\\arduino-ide-extension\\build" 10607 "C:\\Users\\George\\AppData\\Local\\Temp\\arduino\\sketches\\F35C67CE0D6248D2DD027D24058D7622" "C:\\Users\\George\\AppData\\Local\\Temp\\arduino\\sketches\\F35C67CE0D6248D2DD027D24058D7622/core/build.opt" "C:\\Users\\George\\AppData\\Local\\Temp\\.arduinoIDE-unsaved2023319-8764-fq9q4e.1liih\\sketch_apr19a/sketch_apr19a.ino.globals.h" "C:\\Users\\George\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.1.2\\cores\\esp8266/CommonHFile.h"
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000034c (most recent call first):

exit status 3

Compilation error: exit status 3

I see from the output that you are using the latest version of the ESP8266 boards platform (3.1.2). I was interested in this information because I found a bug report about this error message:

That bug was claimed to be fixed by a change made to the platform:

I had a hypothesis that you might be using an outdated version of the platform that didn't include the fix (which was released in 3.0.2), but I see now that I was wrong because you are using a version that includes the fix.

I did find another bug report:

The reporter provided instructions for a workaround for the bug:

https://github.com/esp8266/Arduino/issues/8777#issuecomment-1365555754

uncompress all python37.zip inside 3.7.2-post1 folder

I have no clue whether that would be effective, but if you would like to give that workaround a try, the file is at this path on your computer:

C:\Users\George\AppData\Local\Arduino15\packages\esp8266\tools\python3\3.7.2-post1\python37.zip

:exclamation: If looking for it with your file browser or command line, note that the AppData folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".

It looks like that worked. Thank you very much for the research and for the help.

You are welcome. I'm glad it is working now. Thanks for taking the time to post an update with your findings!

Regards,
Per

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