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

I had the very same error message as EcSync. Although most people are pointing to the python setup being wrong this was not the case for me - aside from the fact that my system had not changed from one day to the next when I got the error, my environment variables matched the python sys.path

EcSync solved the problem by including a missing module but their answer is downvoted. I have to add my voice to say that this error was also caused by a missing module. The clue is in the error message:

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

I simply modified my spec file to include the encodings module and then everything worked. To do this you may need to specify to pyinstaller to use the spec file provided rather than making one from scratch, and you will have to put the path to the missing module in the datas list of Analysis. See here.


Looks like this is happening due to some problem in python installation. Are you sure python is configured properly? Did you add it into ENVIRONMENT VARIABLES?

Most likely it is because your PYTHONPATH ,i.e the one that locates the site-packages is improperly configured. It should work fine once you point PYTHONPATH to the corrent python3.x installation.

Once launch python from your cmd and check which site-packages it is loading.

import sys
sys.path

And then verify what is actually present in your PYTHONHOME