https://promptfoo.dev/ logo
PROMPTFOO_PYTHON not working
# ❓|questions
g
I'm trying to use providers: - 'python:retrieve.py' in my promptfooconfig.yaml but I get the error: Error: Python not found. Tried "C:\Users\gogasawa\AppData\Local\Programs\Python\Python312\python.exe" Please ensure Python is installed and set the PROMPTFOO_PYTHON environment variable to your Python executable path (e.g., 'C:\Python39\python.exe'). Error: Python not found. Tried "C:\Users\gogasawa\AppData\Local\Programs\Python\Python312\python.exe" Please ensure Python is installed and set the PROMPTFOO_PYTHON environment variable to your Python executable path (e.g., 'C:\Python39\python.exe'). at validatePythonPath (C:\Users\gogasawa\opt\node-v20.12.2-win-x64\node_modules\promptfoo\dist\src\python\pythonUtils.js:53:15) at async runPython (C:\Users\gogasawa\opt\node-v20.12.2-win-x64\node_modules\promptfoo\dist\src\python\pythonUtils.js:82:5) at async PythonProvider.executePythonScript (C:\Users\gogasawa\opt\node-v20.12.2-win-x64\node_modules\promptfoo\dist\src\providers\pythonCompletion.js:54:31) at async Evaluator.runEval (C:\Users\gogasawa\opt\node-v20.12.2-win-x64\node_modules\promptfoo\dist\src\evaluator.js:170:28) at async processEvalStep (C:\Users\gogasawa\opt\node-v20.12.2-win-x64\node_modules\promptfoo\dist\src\evaluator.js:527:25) ========= python.exe does exist at that variable > PS > gci env:PROMPT* > > Name Value > ---- ----- > PROMPTFOO_PYTHON C:\Users\gogasawa\AppData\Local\Programs\Python\Python312\python.exe > > > PS > C:\Users\gogasawa\AppData\Local\Programs\Python\Python312\python.exe > Python 3.12.3 (tags/v3.12.3:f6650f9, Apr 9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> Any ideas? Thanks.
m
@garyo4160 I suspect this line is at fault: https://github.com/promptfoo/promptfoo/blob/main/src/python/pythonUtils.ts#L36 I am going to push a fix that does not rely on where and tries python --version instead
g
Thanks. I'd be happy to test.
PS > where python PS > where.exe python C:\Users\gogasawa\AppData\Local\Microsoft\WindowsApps\python.exe C:\Users\gogasawa\AppData\Local\Programs\Python\Python312\python.exe
There is a difference in the Windows Powershell command of "where" and "where.exe".
m
Sorry for the delay: https://github.com/promptfoo/promptfoo/pull/1690 this should resolve it. I will merge and get a release out if the ci passes
g
This fix (v0.89.0) seems to have fixed my problem above. Thanks @michaelmichaelmichael