Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

'encodings' Error#2619

Unanswered
wujun007 asked this question inQ&A
Sep 9, 2025· 3 comments
Discussion options

Excuse me:
The encodings directory exists in the Lib directory of Conda's envs environment, and all the files inside also exist. Why does it still report an error?

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

You must be logged in to vote

Replies: 3 comments

Comment options

I just took over a code base and ran into the same issue.

You must be logged in to vote
0 replies
Comment options

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 settingPythonEngine.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 inPythonEngine.PythonPath. This can happen especially if you set this variable before callingPythonEngine.Initialize() asthis will skip the default module search path discovery!

The way I resolved this was to just add tosys.path instead of overridingPythonEngine.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 agreat solution, but it sure does work.

You must be logged in to vote
0 replies
Comment options

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: ***@***.***>
You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
3 participants
@wujun007@iFreilicht@felix-maini
Converted from issue

This discussion was converted from issue #2616 on September 22, 2025 09:50.


[8]ページ先頭

©2009-2025 Movatter.jp