promptfoo / promptfoo

Test your prompts, agents, and RAGs. Redteaming, pentesting, vulnerability scanning for LLMs. Improve your app's quality and catch problems. Compare performance of GPT, Claude, Gemini, Llama, and more. Simple declarative configs with command line and CI/CD integration.

Home Page:https://www.promptfoo.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: spawn python ENOENT when user try to run promptfoo with python:provider

Starday2009 opened this issue · comments

Hi!
I try to run sample code from examples/python-provider/promptfooconfig.yaml and I get an error

node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: spawn python ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on PythonShell instance at:
    at ChildProcess.<anonymous> (/Users/ogorbachenko/.npm/_npx/81bbc6515d992ace/node_modules/python-shell/index.js:180:18)
    at ChildProcess.emit (node:events:514:28)
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn python',
  path: 'python',
  spawnargs: [
    '/Users/name/.npm/_npx/81bbc6515d992ace/node_modules/promptfoo/dist/src/python/wrapper.py',
    '/Users/name/Projects/dataQA/promptfoo_samples/examples/python-provider/provider.py',
    'call_api',
    '"Write a tweet about bananas"',
    '{"id":"python:provider.py","config":{"someOption":"foobar","basePath":""}}',
    '{"vars":{"topic":"bananas"}}'
  ]
}

Node.js v20.5.1

promptfoo version 0.50.1

Any idea why this is happening?

This means that node isn't able to find the Python executable. By default, this is just python. Ensure that python is installed on your system and that you're in a virtualenv (or whatever is necessary to locate the executable).

If desired, you can manually override the python binary path using the environment variable PROMPTFOO_PYTHON. For example:

PROMPTFOO_PYTHON=venv/bin/python3.9 npx promptfoo@latest eval

Thanks!!