How to Debug using vs code #1805
Replies: 6 comments
-
To run a debugger dockerless do the following. Create a new file
run.py import uvicorn
if __name__ == "__main__":
uvicorn.run("app.main:app", host="0.0.0.0", port=8000, reload=True) Use default launch
Let me know if works. |
Beta Was this translation helpful? Give feedback.
-
But the environment variable cannot be obtained |
Beta Was this translation helpful? Give feedback.
-
@MaxwellEdisons you could re-load them again with dotenv (which should already be present as it used by pydantic) import uvicorn
from dotenv import load_dotenv
load_dotenv("../.env")
if __name__ == "__main__":
uvicorn.run("app.main:app", host="0.0.0.0", port=8002, reload=True) |
Beta Was this translation helpful? Give feedback.
-
Reload dotenv using load_dotenv and reload = True while calling run method import uvicorn
from dotenv import load_dotenv
load_dotenv("./.env")
if __name__ == "__main__":
uvicorn.run("app.main:app", host="yout_local_host", port=your_port_no, reload=True) |
Beta Was this translation helpful? Give feedback.
-
I add the below code in backend/app/main.py
adding attach action in launch.json
and don't forget to add dependency 'debugpy' in the pyproject.toml now, you can rebuild the compose file and you will see the log 'wait for client' then click the attach action |
Beta Was this translation helpful? Give feedback.
-
Here is a nice YT video... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
i'm using this repo for my next project,
but i can't figure out a way for debugging in vs code or connect jupyter server with vs code,
i want to be able to set breakpoints and watch call sack .. etc.
Beta Was this translation helpful? Give feedback.
All reactions