visual studio – VSCode Python Debugger Cannot Execute Third-Party Unit Test Package


I am trying to use the VSCode debugger to run DeepEval for executing LLM-based unit tests. However, I keep encountering an error related to executing the deepeval package. Here is the error message I receive:

$  /usr/bin/env C:\\Users\\myuser\\anaconda3\\envs\\myenv\\python.exe c:\\Users\\myuser\\.vscode\\extensions\\ms-python.debugpy-2024.6.0-win32-x64\\bundled\\libs\\debugpy\\adapter/../..\\debugpy\\launcher 54604 -- C:\\Users\\myuser\\OneDrive\\Desktop\\Coding\\Project/langchain_env/run_deepeval.py test run C:\\Users\\myuser\\OneDrive\\Desktop\\Coding\\Project/tests/test_output_generation.py 

C:\Users\myuser\anaconda3\envs\myenv\lib\site-packages\deepeval\__init__.py:42: UserWarning: You are using deepeval version 0.21.43, however version 0.21.45 is available. You should consider upgrading via the "pip install --upgrade deepeval" command.
  warnings.warn(
C:\Users\myuser\anaconda3\envs\myenv\python.exe: No module named deepeval.__main__; 'deepeval' is a package and cannot be directly executed

Here is my launch.json configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Deepeval",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/langchain_env/run_deepeval.py",
            "args": [
                "test",
                "run",
                "${workspaceFolder}/tests/test_${fileBasename}"
            ],
            "debugStdLib": true,
            "justMyCode": true
        }
    ]
}

Steps I Have Taken:

  1. Ensured that DeepEval is installed in the virtual environment (myenv).
  2. Verified that the Python interpreter is correctly set to the virtual environment in VSCode.
  3. Created a wrapper script (run_deepeval.py) to handle the DeepEval command.

run_deepeval.py Script:

import sys
import subprocess

def main():
    command = [sys.executable, "-m", "deepeval"] + sys.argv[1:]
    result = subprocess.run(command, capture_output=True, text=True)
    print(result.stdout)
    print(result.stderr)

if __name__ == "__main__":
    main()

Question:

How can I configure VSCode to properly execute the DeepEval package within the debugger? Is there something wrong with my launch.json configuration, or is there a better way to set this up?

Leave a Reply

Your email address will not be published. Required fields are marked *