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

[Solved] How can i solve this error "ModuleNotFoundError: No module named 'encodings'" under ubuntu20.04?#2147

Answeredbysmartin-pck
smartin-pck asked this question inQ&A
Discussion options

I want to use Python in a .NET project, and under Windows, I can use Python with the python3.10.dll. Unfortunately, this project needs to run in a Docker container. First, I tried to set up all components in Ubuntu 20.04, but when I linked the python3.10.so to Runtime.PythonDLL, I got the following error:

Python path configuration:
PYTHONHOME = '/usr/lib/python3.10/'
PYTHONPATH = '/usr/lib/:/usr/lib/python3.10/:/usr/lib/python3.10/encodings/'
program name = 'python3'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/usr/local/bin/python3'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = '/usr/local/bin/python3'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'/usr/lib/python3.10/;/usr/lib/python3.10/encodings/;/home/ubuntu/python_packages/lib/python3.10/site-packages/;/home/ubuntu/C#Projject/used_python/',
]
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'

Current thread 0x00007f1641311740 (most recent call first):

My guess is that I'm not setting some necessary library, but I don't know which one it is.

You must be logged in to vote

I could fix it. Unfortunately, under Ubuntu, we cannot use the PYTHONHOME and PYTHONPATH variables. If you use these variables, you will get the "ModuleNotFoundError: No module named 'encodings'" error. If you use your own packages, such as creating a class structure and importing it into your project file, you must copy it to the "dist-packages" folder.

Replies: 1 comment 2 replies

Comment options

I could fix it. Unfortunately, under Ubuntu, we cannot use the PYTHONHOME and PYTHONPATH variables. If you use these variables, you will get the "ModuleNotFoundError: No module named 'encodings'" error. If you use your own packages, such as creating a class structure and importing it into your project file, you must copy it to the "dist-packages" folder.

You must be logged in to vote
2 replies
@filmor
Comment options

That is not true. You probably just set them incorrectly, I see that your path refers to/usr/lib/... while your executable is run from/usr/local/bin.

@iFreilicht
Comment options

The path is indeed set incorrectly. On Linux, you need to use: as the path separator, not; like on Windows. Same issue occurred here:#2217 (comment)

Answer selected bysmartin-pck
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
@smartin-pck@filmor@iFreilicht

[8]ページ先頭

©2009-2025 Movatter.jp