Repository: promptfoo/promptfoo
Issue: Unable to generate prompts from a python files - /bin/sh: python: command not found
Root cause: Documentation Deficiency

Following the example here
https://github.com/promptfoo/promptfoo/tree/main/examples/custom-prompt-function

I have set up prompts in a file called python_prompts.py file.

However when I run the below command, I see the below error.   Is there any setup or virtual environment creation involved in order to run the python code?  I don't any information regarding the same in the example
```
$ promptfoo eval

---
Error: Command failed: python "/Users/[redacted]/Documents/my-learning/promptfoo/one/prompt_python.py" "{\"vars\":{\"topic\":\"the weather\",\"_conversation\":[]}}"
/bin/sh: python: command not found

    at checkExecSyncError (node:child_process:885:11)
    at execSync (node:child_process:957:15)
    at Object.promptFunction [as function] (/usr/local/lib/node_modules/promptfoo/dist/src/prompts.js:195:36)
    at renderPrompt (/usr/local/lib/node_modules/promptfoo/dist/src/evaluator.js:64:45)
    at Evaluator.runEval (/usr/local/lib/node_modules/promptfoo/dist/src/evaluator.js:136:38)
    at /usr/local/lib/node_modules/promptfoo/dist/src/evaluator.js:464:36
    at /usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:151:38
    at replenish (/usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:448:21)
    at /usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:453:13 {
```

The python prompt type assumes you have a `python` binary installed.  If
you're not already using python, I recommend using a javascript prompt
because you already have that runtime set up if you're using promptfoo :)

On Thu, Nov 9, 2023 at 12:36 PM gautam-goudar ***@***.***>
wrote:

> Following the example here
>
> https://github.com/promptfoo/promptfoo/tree/main/examples/custom-prompt-function
>
> I have set up prompts in a file called python_prompts.py file.
>
> However when I run the below command, I see the below error. Is there any
> setup or virtual environment creation involved in order to run the python
> code? I don't any information regarding the same in the example
>
> $ promptfoo eval
>
> ---
> Error: Command failed: python "/Users/[redacted]/Documents/my-learning/promptfoo/one/prompt_python.py" "{\"vars\":{\"topic\":\"the weather\",\"_conversation\":[]}}"
> /bin/sh: python: command not found
>
>     at checkExecSyncError (node:child_process:885:11)
>     at execSync (node:child_process:957:15)
>     at Object.promptFunction [as function] (/usr/local/lib/node_modules/promptfoo/dist/src/prompts.js:195:36)
>     at renderPrompt (/usr/local/lib/node_modules/promptfoo/dist/src/evaluator.js:64:45)
>     at Evaluator.runEval (/usr/local/lib/node_modules/promptfoo/dist/src/evaluator.js:136:38)
>     at /usr/local/lib/node_modules/promptfoo/dist/src/evaluator.js:464:36
>     at /usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:151:38
>     at replenish (/usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:448:21)
>     at /usr/local/lib/node_modules/promptfoo/node_modules/async/dist/async.js:453:13 {
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/promptfoo/promptfoo/issues/272>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACLYJXYGJBXBPUNNC2TLPDYDU5EJAVCNFSM6AAAAAA7FFDF4KVHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4DMMZWGQZDOOI>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>


I have python installed and also created a .venv environment in the root folder where the example is being run

```
/Users/[redacted]/Documents/my-learning/promptfoo/one$ which python3

---
/Users/[redcted]/Documents/my-learning/promptfoo/.venv/bin/python3

```

Ah I see.  You probably need to alias `python` to `python3` via symlink for
example.  Make sure `python` points to an executable and it should work.

On Thu, Nov 9, 2023 at 1:11 PM gautam-goudar ***@***.***>
wrote:

> I have python installed and also created a .venv environment in the root
> folder where the example is being run
>
> /Users/[redacted]/Documents/my-learning/promptfoo/one$ which python3
>
> ---
> /Users/[redcted]/Documents/my-learning/promptfoo/.venv/bin/python3
>
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/promptfoo/promptfoo/issues/272#issuecomment-1804691532>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AACLYJU7GDA2DITBL5AC6ATYDVBIXAVCNFSM6AAAAAA7FFDF4KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBUGY4TCNJTGI>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>


With 0.26.5, promptfoo now supports the `PROMPTFOO_PYTHON` environment variable, which you can use to override executable name or path (`python3` in your case).