Activity
Mon
Wed
Fri
Sun
Dec
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
What is this?
Less
More

Memberships

AI Developer Accelerator

Public โ€ข 3.8k โ€ข Free

1 contribution to AI Developer Accelerator
Debugging in vscode
I'm used to hooking up a python debugger in vscode to run and debug and trace code to see what is going on. How the heck do I do that using crewai? when I run `python main.py` it says there are dependencies missing, when I run `crewai flow demo_flow` it works fine. how do i configure launch.json to debug?
0
1
New comment 5d ago
1 like โ€ข 5d
aider helped with some better prompting. I was in wrong folders and I wasn't running it as a module so relative imports wern't working ------- To set up debugging for a Python script with relative imports in Visual Studio Code using `launch.json`, you can configure the `launch.json` file to handle the module execution and set the `PYTHONPATH`. Here's how you can do it: 1. **Open your project in Visual Studio Code**. 2. **Open the Debug view** by clicking on the Debug icon in the Activity Bar on the side of the window. 3. **Create or open `launch.json`**: - Click on the gear icon at the top of the Debug panel and select "Add Configuration..." - If you don't have a `launch.json` file yet, VS Code will create one for you. 4. **Add a new configuration** for your script. Here is an example configuration you can add to your `launch.json`: ```json { "version": "0.2.0", "configurations": [ { "name": "Python: Module", "type": "python", "request": "launch", "module": "5_flows_with_crews.demo_flow.src.demo_flow.main", "cwd": "${workspaceFolder}", "env": { "PYTHONPATH": "${workspaceFolder}" }, "console": "integratedTerminal" } ] } ``` - **`module`**: This specifies the module to run. Use the dot notation to specify the path to your `main.py` file as a module. - **`cwd`**: This sets the current working directory to the root of your workspace. - **`env`**: This sets the `PYTHONPATH` environment variable to the root of your workspace, allowing Python to resolve the relative imports correctly. - **`console`**: This specifies where to display the output. You can choose between `integratedTerminal` or `externalTerminal`. 5. **Save the `launch.json` file**. 6. **Start debugging**: - Select the configuration you just added from the dropdown in the Debug panel. - Click the green play button to start debugging.
1-1 of 1
Asad Jobanputra
1
4points to level up
@asad-jobanputra-5227
ai developer/cto

Active 5d ago
Joined Nov 17, 2024
powered by