Skip to content

[Bug]: ModuleNotFoundError: No module named 'encodings' #703

@Shamsidinkhon

Description

@Shamsidinkhon

What happened?

Upgrading rules_py from 1.3.2 to 1.6.6 version breaks Python extension (https://open-vsx.org/extension/ms-python/python) in IDE (Cursor and Vscode) with the following error:

~/shams/.python3-bazel.venv/bin/python -I ~/.cursor-server/extensions/ms-python.python-2025.6.1-linux-x64/python_files/get_output_via_markers.py ~/.cursor-server/extensions/ms-python.python-2025.6.1-linux-x64/python_files/interpreterInfo.py
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/home/user/.cache/bazel/_bazel_shams/2d66f777601ac4cdc56880586b3f83ab/execroot/_main/bazel-out/k8-fastbuild/bin/venv.runfiles/_main/.venv/bin/python3'
  isolated = 1
  environment = 0
  user site = 0
  import site = 1
  sys._base_executable = '/home/user/.cache/bazel/_bazel_shams/2d66f777601ac4cdc56880586b3f83ab/execroot/_main/bazel-out/k8-fastbuild/bin/venv.runfiles/_main/.venv/bin/python3'
  sys.base_prefix = '/install'
  sys.base_exec_prefix = '/install'
  sys.platlibdir = 'lib'
  sys.executable = '/home/user/.cache/bazel/_bazel_shams/2d66f777601ac4cdc56880586b3f83ab/execroot/_main/bazel-out/k8-fastbuild/bin/venv.runfiles/_main/.venv/bin/python3'
  sys.prefix = '/install'
  sys.exec_prefix = '/install'
  sys.path = [
    '/install/lib/python39.zip',
    '/install/lib/python3.9',
    '/install/lib/lib-dynload',
  ]
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 0x000078e3c60dd740 (most recent call first):
<no Python frame>

I can see sys.path starts from the root, shouldn't it point to /home/user/.cache/bazel/_bazel_shams/2d66f777601ac4cdc56880586b3f83ab/execroot/_main/bazel-out/k8-fastbuild/bin/venv.runfiles/_main/.venv/lib ?

Version

Development (host) and target OS/architectures: Debian GNU/Linux 12 (bookworm) / x86_64

Output of bazel --version: 8.4.1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

Install Python extension https://open-vsx.org/extension/ms-python/python (2025.6.1 version) in Vscode or Cursor. Check "Output" of "Python" for errors.

Any other information?

py_venv(
    name = "venv",
    package_collisions = "ignore",
    venv_name = ".python3-bazel.venv",
    deps = VENV_DEPS_3_9,
)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions