1

I'm trying to use Visual Studio Code (VSC) as IDE for my QGIS plugins with the Python extension, but something doesn't work as expected. I've been reading about the PyCharm config from Gary S. but I couln't apply it to VSC.

Should I use an .env file? What should I set in the settings.json? How to call batch files when VSC starts?

  • All ide's i know, a batch file is used to start them. The starting procedure is analoque to the batch file to start qgis. There are also differences between qgis2 and qgis3. – Andreas Müller Aug 7 '18 at 19:21
2

Create an empty file named visual_studio_code_for_qgis.bat

Paste this:

@echo off
path %PATH%;C:\Program Files\QGIS 3.2\bin
path %PATH%;C:\Program Files\QGIS 3.2\apps\grass\grass-7.4.1\lib
path %PATH%;C:\Program Files\QGIS 3.2\apps\Qt5\bin
path %PATH%;C:\Program Files\QGIS 3.2\apps\Python36\Scripts

set PYTHONPATH=%PYTHONPATH%;C:\Program Files\QGIS 3.2\apps\qgis\python
set PYTHONHOME=C:\Program Files\QGIS 3.2\apps\Python36   

start "VisualStudioCode for QGIS" /B "C:\Users\Zoran\AppData\Local\Programs\Microsoft VS Code\Code.exe" %*

Update paths if necessary.

Run the visual_studio_code_for_qgis.bat

More details can be found here: http://gis-expert.com/wp/2018/10/15/how-to-setup-qgis-3-and-visual-studio-code-plugin-development-windows/

  • I've read your answer and your article (sorry for the delay) but I can't make it work following your instructions. Paths are really different, especially because I've both 2.18 and 3.4 versions installed through the OSGeo4W installer (64 bits). Otherwise, in your article, you should not advise to install packages in the Python system installation, especially with admin level (use of --user option is preferred). For example, PyQt5 is already included into QGIS installation (try to import it into the python-qgis interpreter launched from OSGeo4W Shell). – Guts Jan 17 at 6:15
  • You've chosen to install QGIS differently than Zoran suggests in his instructions. Osgeo4w organizes things differently than if you use QGIS standalone installer which is how Zoran suggests. – cndnflyr Jul 4 at 22:59
0

Try this batch file for an Osgeo4w QGIS install.

https://github.com/frankbroniewski/visual-studio-code-qgis

0

We didn't want to use a script to open our workspace, so we finally found out how to configure Visual Studio Code through the settings.json file: https://github.com/isogeo/isogeo-plugin-qgis/blob/master/.vscode/settings.json

The requirement is to have QGIS LTR installed with OSGeo4W on the computer. We automated this step with the command-line: https://gist.github.com/Guts/6303dc5eb941eb24be3e27609cd46985

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.