Skip to content

uv python cannot find PYTHONHOME when symlinked from inside of directory with pyvenv.cfg with wrong home value #12743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hoodmane opened this issue Apr 8, 2025 · 2 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@hoodmane
Copy link

hoodmane commented Apr 8, 2025

Summary

I'm sorry this is a bit of a weird bug report. I swear it has a real use case, see pyodide/pyodide-build#143.

$ uv python install 3.12
$ echo "home = junk" > pyveng.cfg
$ ln -s /usr/bin/python3.12 system-python-symlink
$ ln -s $(uv python find python3.12) uv-python-symlink
$ ./system-python-symlink -c 'print("hi!")'
hi!
$ ./uv-python-symlink -c 'print("hi!")'
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 = './uv-python-symlink'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/install/lib/python3.12'
  sys._base_executable = '/home/rchatham/.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 = '/home/rchatham/Documents/programming/tmp/uv-symlink-bug/uv-python-symlink'
  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 0x0000745b37819740 (most recent call first):
  <no Python frame>

Platform

Ubuntu 22

Version

uv 0.5.23

Python version

Either Python 3.12 or Python 3.13

@hoodmane hoodmane added the bug Something isn't working label Apr 8, 2025
@zanieb
Copy link
Member

zanieb commented Apr 8, 2025

Duplicate of #8821

Unfortunately this is a known problem.

Lots of discussion in astral-sh/python-build-standalone#380 and python/cpython#128670 too

@zanieb zanieb added the duplicate This issue or pull request already exists label Apr 8, 2025
@hoodmane
Copy link
Author

hoodmane commented Apr 8, 2025

Thanks!

@hoodmane hoodmane closed this as completed Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants