pypa/pip · error · ResolutionError
Script not found in metadata at
Error message
Script {script!r} not found in metadata at {self.egg_info!r} What it means
Raised as ResolutionError by NullProvider.run_script() when the requested script name is not present in the distribution's EGG-INFO/scripts metadata. The message includes the script name and the egg_info path where it was expected. This means the package metadata does not declare that script.
Solutions
- Verify the script name against the package's EGG-INFO/scripts listing (dist.get_metadata_lines('scripts') or check entry points).
- Correct the script name spelling/casing.
- Use entry points (iter_entry_points) instead of run_script for modern package-script invocation.
Example fix
// before
dist.run_script('runServer', ns) # name doesn't exist
// after
scripts = dist.get_metadata_lines('scripts')
# pick the correct name from `scripts`
dist.run_script(actual_name, ns) Defensive patterns
Strategy: validation
Validate before calling
script_path = 'scripts/' + script_name
if not dist.has_metadata(script_path):
raise KeyError(f'{script_name} not in {dist} scripts')
dist.run_script(script_name, ns) Type guard
def script_exists(dist, name: str) -> bool:
return dist.has_metadata('scripts/' + name) Try / catch
try:
dist.run_script(name, ns)
except ResolutionError as e:
print(e) Prevention
- Check has_metadata('scripts/<name>') before calling run_script.
- Prefer entry points over run_script for modern packaging.
When it happens
Trigger: Calling dist.run_script('my_script', namespace) when 'scripts/my_script' is not listed in the package's EGG-INFO metadata (e.g. has_metadata('scripts/my_script') is False).
Common situations: A typo in the script name; the script was removed in a newer version of the package; the package was installed from a wheel without script metadata; calling run_script on a distribution that doesn't bundle that entry.
Related errors
- Duplicate entry point
- Entry points must be listed in groups
- Error decoding metadata for
- Error parsing entry points for
- Invalid section heading
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/d1068abdae694a2d.
Report an issue: GitHub.
Appendix: source
Thrown at src/pip/_vendor/pkg_resources/__init__.py:1701
def resource_isdir(self, resource_name: str):
return self._isdir(self._fn(self.module_path, resource_name))
def metadata_isdir(self, name: str) -> bool:
return bool(self.egg_info and self._isdir(self._fn(self.egg_info, name)))
def resource_listdir(self, resource_name: str):
return self._listdir(self._fn(self.module_path, resource_name))
def metadata_listdir(self, name: str) -> list[str]:
if self.egg_info:
return self._listdir(self._fn(self.egg_info, name))
return []
def run_script(self, script_name: str, namespace: dict[str, Any]):
script = 'scripts/' + script_name
if not self.has_metadata(script):
raise ResolutionError(
"Script {script!r} not found in metadata at {self.egg_info!r}".format(
**locals()
),
)
script_text = self.get_metadata(script).replace('\r\n', '\n')
script_text = script_text.replace('\r', '\n')
script_filename = self._fn(self.egg_info, script)
namespace['__file__'] = script_filename
if os.path.exists(script_filename):
source = _read_utf8_with_fallback(script_filename)
code = compile(source, script_filename, 'exec')
exec(code, namespace, namespace)
else:
from linecache import cache
cache[script_filename] = (
len(script_text),View on GitHub (pinned to f399c37189)