uv/crates/uv-python
konstin a2b603f8fe Show a better hint for broken PBS venvs
For some reason, I'm encountering broken PBS venvs again (https://github.com/astral-sh/python-build-standalone/issues/380). Instead of showing the obscure error to the user, we point them to the PBS bug and ask them to run `uv venv`.

```
$ uv sync
error: Querying Python at `/tmp/uv/tests/.tmpwXZRTI/temp/.venv/bin/python3` failed with exit status exit status: 1

[stderr]
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 = '/tmp/uv/tests/.tmpwXZRTI/temp/.venv/bin/python3'
  isolated = 1
  environment = 0
  user site = 0
  safe_path = 1
  import site = 1
  is in build tree = 0
  stdlib dir = '/install/lib/python3.12'
  sys._base_executable = '/home/konsti/.local/share/uv/python/cpython-3.12.9-linux-x86_64-gnu/bin/python3.12'
  sys.base_prefix = '/install'
  sys.base_exec_prefix = '/install'
  sys.platlibdir = 'lib'
  sys.executable = '/tmp/uv/tests/.tmpwXZRTI/temp/.venv/bin/python3'
  sys.prefix = '/install'
  sys.exec_prefix = '/install'
  sys.path = [
    '/install/lib/python312.zip',
    '/install/lib/python3.12',
    '/install/lib/python3.12/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 0x000078e48b835740 (most recent call first):
  <no Python frame>
```

```
$ uv-debug sync
  error: Can't use Python at `/tmp/uv/tests/.tmpwXZRTI/temp/.venv/bin/python3`
    Caused by: Python is missing PYTHONHOME. If you are using a managed Python interpreter, this is a known bug (https://github.com/astral-sh/python-build-standalone/issues/380). You can recreate the virtual environment with `uv venv`.
```
2025-12-11 16:08:57 +01:00
..
python Fix Pyston tags (#16972) 2025-12-04 10:18:41 +01:00
src Show a better hint for broken PBS venvs 2025-12-11 16:08:57 +01:00
.gitignore minify and filter embed managed pythons json on compile time (#12967) 2025-04-30 15:51:03 -04:00
Cargo.toml Bump version to 0.9.17 (#17058) 2025-12-09 16:36:00 -06:00
README.md Bump version to 0.9.17 (#17058) 2025-12-09 16:36:00 -06:00
build.rs chore(🧹): const env var usage cleanup (#16950) 2025-12-02 22:16:46 -08:00
download-metadata.json Sync latest Python releases (#17057) 2025-12-09 22:30:11 +00:00
fetch-download-metadata.py Allow selection of debug build interpreters (#11520) 2025-09-12 13:32:22 +00:00

README.md

uv-python

This crate is an internal component of uv. The Rust API exposed here is unstable and will have frequent breaking changes.

This version (0.0.7) is a component of uv 0.9.17. The source can be found here.

See uv's crate versioning policy for details on versioning.