python_subprocess_env: Environment for spawning Python child processes

View source: R/utils.R

python_subprocess_envR Documentation

Environment for spawning Python child processes

Description

R prepends its own and related library directories to LD_LIBRARY_PATH (its lib directory plus system paths such as ⁠/usr/lib/x86_64-linux-gnu⁠). When a Python child inherits that, the dynamic loader can resolve a system libpython ahead of the interpreter's own; the interpreter then computes a different sys.prefix and its site module drops site-packages from sys.path, so pip-installed packages (for example the Python shinylive CLI) become unimportable and the process fails with ⁠No module named ...⁠ even though the package is installed. Python resolves its own libraries via rpath, so LD_LIBRARY_PATH is removed for Python children. A no-op on platforms / installs where it is not set (Windows, macOS, most user setups).

Usage

python_subprocess_env()

Value

A named character vector suitable for the env argument of processx::run().


shinyelectron documentation built on Dec. 3, 2026, 9:07 a.m.