- Notifications
You must be signed in to change notification settings - Fork768
-
Excuse me: Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Replies: 3 comments
-
I just took over a code base and ran into the same issue. |
BetaWas this translation helpful?Give feedback.
All reactions
-
There are two potential reasons for this: First (and most likely from what I've seen in the questions here) is that you're using The other potential problem is that you're missing some crucial parths in The way I resolved this was to just add to I'm not sure this is agreat solution, but it sure does work. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thank you, I'll give it a try …------------------ 原始邮件 ------------------发件人: ***@***.***>;发送时间: 2025年11月27日(星期四) 下午4:22收件人: ***@***.***>;抄送: ***@***.***>; ***@***.***>;主题: Re: [pythonnet/pythonnet] 'encodings' Error (Discussion#2619)There are two potential reasons for this: First (and most likely from what I've seen in the questions here) is that you're using ; as a path separator when setting PythonEngine.PythonPath. This is correct on Windows, but on Linux you need to use :, see also#2217 (comment)The other potential problem is that you're missing some crucial parths in PythonEngine.PythonPath. This can happen especially if you set this variable before calling PythonEngine.Initialize() as this will skip the default module search path discovery!The way I resolved this was to just add to sys.path instead of overriding PythonEngine.PythonPath: Runtime.PythonDLL = pythonDLLPath; PythonEngine.Initialize(); PythonEngine.BeginAllowThreads(); using (Py.GIL()) { dynamic sys = Py.Import("sys"); sys.path.append(singlePackagePath); sys.path.extend(multiplePackagePaths); Console.WriteLine("Python version: {0}", sys.version); Console.WriteLine("PythonPath: {0}", PythonEngine.PythonPath); Console.WriteLine("sys.path: {0}", sys.path); }I'm not sure this is a great solution, but it sure does work.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***> |
BetaWas this translation helpful?Give feedback.
All reactions
This discussion was converted from issue #2616 on September 22, 2025 09:50.