--- title: 'Visual Studio Code for Python project(poetry and pipenv)' disqus: diabee --- # Visual Studio Code for some projects (springboot poetry and pipenv) [TOC] ## Visual Studio Code 相關debugger 設定介面和操作 > Extention ![Screenshot 2025-01-21 at 2.27.55 PM](https://hackmd.io/_uploads/Byhu022v1g.png) > Run and Debug ![Screenshot 2025-01-21 at 2.24.14 PM](https://hackmd.io/_uploads/BJ3qp33Pyl.png) ## Pyenv 安裝 可以參考之前[文章](https://hackmd.io/@Diabee/pyenv-install) ## Pipenv for flask > Run and Debug > create a launch.json file > select Python Debugger > select Flask > select app_main.py >![Screenshot 2025-01-21 at 2.30.29 PM](https://hackmd.io/_uploads/ryvzk62P1l.png) >![Screenshot 2025-01-21 at 2.31.36 PM](https://hackmd.io/_uploads/r1Md163Dye.png) >![Screenshot 2025-01-21 at 2.33.36 PM](https://hackmd.io/_uploads/ry8ygT2vJg.png) vscode => launch.json ```json=1 { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Flask", "type": "debugpy", "request": "launch", "module": "flask", "env": { "FLASK_APP": "app_main.py", "FLASK_DEBUG": "1" }, "args": [ "run", "--no-debugger", "--no-reload" ], "jinja": true, "autoStartBrowser": false } ] } ``` ## 選對 Python Interpreter(重要) 打開 Command Palette (Ctrl+Shift+P) 輸入 Python: Select Interpreter --- >F5 > debuggger ![Screenshot 2025-01-21 at 2.44.20 PM](https://hackmd.io/_uploads/BJWUGTnDkg.png) ## Poetry for fastapi vscode => launch.json ```json=1 { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python Debugger: FastAPI", "type": "debugpy", "request": "launch", "module": "uvicorn", "args": [ "src.main:app", "--reload" ], "jinja": true } ] } ``` >其他跟前一個主題的操作很類似 ## VSCode for Springboot project > ## 問題發生處理 > 如果有咬死版本,且讓你無法切換python版本,可以下deactivate指令,重新pyenv local 版本 和 pipenv install(shell)切換 或著[參考文章後面的問題](https://hackmd.io/@Diabee/pyenv-install)