Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

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

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:UsersuserAppDataLocalProgramsPythonPython37-32python37.zip', 'C:UsersuserAppDataLocalProgramsPythonPython37-32DLLs', 'C:UsersuserAppDataLocalProgramsPythonPython37-32lib', 'C:UsersuserAppDataLocalProgramsPythonPython37-32', 'C:UsersuserAppDataRoamingPythonPython37site-packages', 'C:UsersuserAppDataLocalProgramsPythonPython37-32libsite-packages', 'C:UsersuserAppDataLocalProgramsPythonPython37-32libsite-packageswin32', 'C:UsersuserAppDataLocalProgramsPythonPython37-32libsite-packageswin32lib', 'C:UsersuserAppDataLocalProgramsPythonPython37-32libsite-packagesPythonwin']

Any help is appreciated

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...