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

EcSync picture EcSync · Jan 8, 2019 · Viewed 39.3k times · Source

I have created a .exe file of a simple script with intentions to run it on a server however I cannot seem to figure out what this fault means or find any answers online. The fault code is as follows:

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

Current thread 0x00003c8c (most recent call first):

To get this far I used pyinstaller

pyinstaller --onefile MyScript.py

When this didn't work I also tried

pyinstaller MyScript.py

I am running on windows 10, python 3.7 within admin command prompt, within a C:\ file directory.

My sys.path is

['', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32\python37.zip', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32\DLLs', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32', 'C:\Users\user\AppData\Roaming\Python\Python37\site-packages', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32\lib', 'C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\Pythonwin']

Any help is appreciated

Answer

Vineeth Sai picture Vineeth Sai · Jan 8, 2019

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