Skip to content

Error with Python 3.11 installed by uv #801

@trprado-via

Description

@trprado-via

Fedora: 42
uv: 0.8.18

I use uv in a project and run my unit tests in a GitHub or locale action with pre-commit using the standalone version of Python 3.11 from the uv Python build. However, I started getting this error with Python 3.11 this week.

nox -f tests/noxfile.py 
nox > Running session tests-3.11
nox > Creating virtual environment (virtualenv) using python3.11 in .nox/tests-3-11
nox > python -m pip install 'pytest>=8.4.1'
nox > Command python -m pip install 'pytest>=8.4.1' failed with exit code 1:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = '/mnt/DATA/Dev/via/VIA/repositories/datahub/kuantum/kuantum-glue-process-calc/tests/.nox/tests-3-11/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/install/lib/python3.11'
  sys._base_executable = '/home/trprado/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/bin/python3.11'
  sys.base_prefix = '/install'
  sys.base_exec_prefix = '/install'
  sys.platlibdir = 'lib'
  sys.executable = '/mnt/DATA/Dev/via/VIA/repositories/datahub/kuantum/kuantum-glue-process-calc/tests/.nox/tests-3-11/bin/python'
  sys.prefix = '/install'
  sys.exec_prefix = '/install'
  sys.path = [
    '/install/lib/python311.zip',
    '/install/lib/python3.11',
    '/install/lib/python3.11/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 0x00007f96f3b3ec40 (most recent call first):
  <no Python frame>

If I use the command 'uv run', the error does not occur. However, if I use Python 3.11 installed in the path by uv, this error is displayed in the terminal.

I tried using other versions of 3.11 (I use 3.11 because my project is for Glue 5).

uv python ls:

cpython-3.11.12-linux-x86_64-gnu                         /home/trprado/.local/share/uv/python/cpython-3.11.12-linux-x86_64-gnu/bin/python3.11
cpython-3.11.11-linux-x86_64-gnu                         /home/trprado/.local/bin/python3.11 -> /home/trprado/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/bin/python3.11
cpython-3.11.11-linux-x86_64-gnu                         /home/trprado/.local/share/uv/python/cpython-3.11.11-linux-x86_64-gnu/bin/python3.11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions