-3

I have started to use PyQGIS but sometimes processes take too long.

So, I want to know if is it possible to use PyQGIS functions directly from a Python IDE (Now I use Jupyter notebooks but it wouldn't be a problem to use PyCharm, Spyder or another one).

José Rojas
  • 169
  • 1
  • 8

1 Answers1

1

I keep this pyQGIS.cmd file around to make my PyCharm QGIS aware:

@echo off

SET QGIS_ROOT=C:\Program Files\QGIS 3.22.2 SET QT_DIR=qt5 SET GRASS_DIR=grass78 SET PYTHON_DIR=Python39

call "%QGIS_ROOT%\bin\o4w_env.bat"

call "%QGIS_ROOT%\apps\grass%GRASS_DIR%\etc\env.bat"

@echo off

path %PATH%;%QGIS_ROOT%\apps\qgis\bin

path %PATH%;%QGIS_ROOT%\apps\grass%GRASS_DIR%\lib

path %PATH%;%QGIS_ROOT%\apps%QT_DIR%\bin

path %PATH%;%QGIS_ROOT%\apps%PYTHON_DIR%\Scripts

set PYTHONPATH=%PYTHONPATH%;%QGIS_ROOT%\apps\qgis\python

set PYTHONHOME=%QGIS_ROOT%\apps%PYTHON_DIR%

start "PyQGIS" /B "C:\Program Files\JetBrains\PyCharm 2020.3.2\bin\pycharm64.exe"

You will have to adjust the paths to make it work on your system and update them when you update QGIS.

Just add a shortcut pointing to it to %APPDATA%\Microsoft\Windows\Start Menu\Programs and you can call it from the start menu.

Edit:

Original source: https://silverspringenergy.com/using-pycharm-as-an-ide-for-qgis-3-plugin-development-2/

greedom
  • 26
  • 2