hankcs/HanLP · error · RuntimeError
eval.pl exited with error code {exitcode} and error message
Error message
eval.pl exited with error code {exitcode} and error message {err} and output {out}. What it means
The dependency-parsing evaluator shells out to the external Perl script eval.pl (CONLLX_EVAL) to compute UAS/LAS. If the Perl process exits with a nonzero status, HanLP re-raises its stderr/stdout as a RuntimeError.
Source
Thrown at hanlp/metrics/parsing/conllx_eval.py:33
Args:
gold_file(str): The gold conllx file
pred_file(str): The pred conllx file
Returns:
"""
gold_file = get_resource(gold_file)
fixed_pred_file = tempfile.NamedTemporaryFile().name
copy_cols(gold_file, pred_file, fixed_pred_file, keep_comments=False)
if gold_file.endswith('.conllu'):
fixed_gold_file = tempfile.NamedTemporaryFile().name
copy_cols(gold_file, gold_file, fixed_gold_file, keep_comments=False)
gold_file = fixed_gold_file
exitcode, out, err = get_exitcode_stdout_stderr(f'perl {CONLLX_EVAL} -q -b -g {gold_file} -s {fixed_pred_file}')
if exitcode:
raise RuntimeError(f'eval.pl exited with error code {exitcode} and error message {err} and output {out}.')
lines = out.split('\n')[-4:]
las = int(lines[0].split()[3]) / int(lines[0].split()[5])
uas = int(lines[1].split()[3]) / int(lines[1].split()[5])
return uas, las
def copy_cols(gold_file, pred_file, copied_pred_file, keep_comments=True):
"""Copy the first 6 columns from gold file to pred file
Args:
gold_file:
pred_file:
copied_pred_file:
keep_comments: (Default value = True)
Returns:
View on GitHub (pinned to ddb1299bdd)
Solutions
- Ensure perl is installed and on PATH (perl -v).
- Inspect the reported stderr message — it usually states the real cause (e.g. 'No such file or directory' for missing eval.pl or an unreadable input file).
- Validate that both gold and prediction files exist and are well-formed CoNLL-X (tab-separated, sentences separated by blank lines) before evaluating.
- If you cannot install perl, use a pure-Python UAS/LAS implementation instead of this wrapper.
Defensive patterns
Strategy: try-catch
Validate before calling
import shutil
assert shutil.which('perl'), 'perl is required for conllx eval' Try / catch
try:
uas, las = evaluate(gold, pred)
except RuntimeError as e:
log.error('eval.pl failed: %s', e)
raise Prevention
- Pre-check shutil.which('perl') before evaluation.
- Validate CoNLL files (column counts, blank-line separators) with a small parser before eval.
When it happens
Trigger: Calling conllx_eval.evaluate(gold_file, pred_file) when perl is missing/broken, eval.pl is not found at the expected path, or the gold/pred CoNLL-X files are malformed enough that eval.pl itself fails.
Common situations: Environments without perl installed (Windows, slim Docker images); running from a directory where the bundled eval.pl cannot be resolved; corrupted or empty prediction files produced by a failed parse step.
Related errors
- {err} The command is: {cmd}
- Unsupported argument length: {item}
- If no `decoder_input_ids` or `decoder_inputs_embeds` are pas
- Unsupported version {version}
- Conversion failed with code {code} for {src}. The err messag
AI-assisted analysis of hankcs/HanLP@ddb1299bdd (2026-08-27).
Data as JSON: /api/errors/7781c56a119fda7c.
Report an issue: GitHub.