0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

debugvsプラグインによる、QGIS+VSCodeでのデバック環境を構築「結局、動作未確認💦」

Last updated at Posted at 2025-03-16

【おち】

 
 ん!これは、、、このデバッグ方法は、QGISにインストール上のプラグインで実行するらしい。
ということ、おおざっぱな私としては、VSCODでインストールプラグインを直接編集して、プラグインリローダを利用して、デバッグで十分なのではという疑問が。。。
 image.png

 最後まで読まずに、自分の環境に併せて、設定していったが、結果、今回は実際に動くか試さなかった。。。
 が!今後のために残しておこう!残念。
 最初に、結論を読んでおけばよかった。💦

【環境】

Windows 11
QGIS 3.42
C:\github\yr-qgis-launcher に 「yr-qgis-launcher」をインストール
 今回は QGIS 3.42 ポータブル版

最初の環境構築(VSCodeのインストール)

VSCodeのインストール
https://azure.microsoft.com/ja-jp/products/visual-studio-code/

VSCodeでのデバック準備

ptvsdのインストール

・ OSGeo4Wのshellを起動する
C:\github\yr-qgis-launcher\QGIS3.42.0\qgis でcmdを起動する
image.png

・pipをインストールする
python -m ensurepip --default-pip

・VSCodeでのデバック用にptvsdをインストール
python -m pip install ptvsd
python.exe -m pip install --upgrade pip

QGISにDebug用プラグイン「debugvs」をインストールする

プラグインの管理とインストールを起動
メニューバー→プラグイン→プラグインの管理とインストール
image.png

VSCode側のデバック設定を作成

launch.jsonを作成する
.vscode/launch.json
launch.jsonにリモートデバック用の設定を記載する
例)C:\github\yr-qgis-easyinstantprint のプラグイン

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Remote Attach",
      "type": "python",
      "request": "attach",
      "connect": {
        "host": "localhost",
        "port": 5678
      },
      "pathMappings": [
        {
          "localRoot": "${C:\github\yr-qgis-easyinstantprint}",
          "remoteRoot": "${C:\github\yr-qgis-easyinstantprint}"
        }
      ],
      "justMyCode": false
    }
  ]
}

localRoot
C:\github\yr-qgis-easyinstantprint
remoteRoot「直接コードを編集するため、localRootと同じ」
C:\github\yr-qgis-easyinstantprint
justMyCode
 他のコード内までデバックを行ないたい場合、falseにする

デバックを実行する

・QGISを起動する
・debugvsのEnable Debug for Visual Studioを実行する
image.png
・VSCodeでPython: Remote Attach「launch.jsonで設定」でデバックを実行する
image.png
image.png
・VSCode上でブレイクポイントを設定し、QGISでプラグインを実行する

【参考】
https://qiita.com/ikura1/items/bc1a5263c366ed477f6a

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?