astral-sh/uv · error
Requirements environment has no site packages directory
Error message
Requirements environment has no site packages directory
What it means
Error "Requirements environment has no site packages directory" thrown in astral-sh/uv.
Source
Thrown at crates/uv/src/commands/project/run.rs:1077
false,
uv_virtualenv::Seed::Disabled,
false,
)
})
.transpose()?
.map(EphemeralEnvironment::from);
// If we're running in an ephemeral environment, add a path file to enable loading from the
// `--with` requirements environment and the project environment site packages.
//
// Setting `PYTHONPATH` is insufficient, as it doesn't resolve `.pth` files in the base
// environment. Adding `sitecustomize.py` would be an alternative, but it can be shadowed by an
// existing such module in the python installation.
if let Some(ephemeral_env) = ephemeral_env.as_ref() {
if let Some(requirements_env) = requirements_env.as_ref() {
let requirements_site_packages =
requirements_env.site_packages().next().ok_or_else(|| {
anyhow!("Requirements environment has no site packages directory")
})?;
let mut base_site_packages = base_interpreter
.runtime_site_packages()
.iter()
.map(|path| Cow::Borrowed(path.as_path()))
.chain(base_interpreter.site_packages())
.peekable();
if base_site_packages.peek().is_none() {
return Err(anyhow!("Base environment has no site packages directory"));
}
let overlay_content = format!(
"import site; {}",
std::iter::once(requirements_site_packages)
.chain(base_site_packages)
.dedup()
.inspect(|path| debug!("Adding `{}` to site packages", path.display()))
.map(|path| format!("site.addsitedir({})", path.escape_for_python()))View on GitHub (pinned to f1a42680ff)
When it happens
Trigger: Thrown at crates/uv/src/commands/project/run.rs:1077 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of astral-sh/uv@f1a42680ff (2026-08-16).
Data as JSON: /api/errors/8e2e67dd26abf513.
Report an issue: GitHub.