0

I am trying to add the PyQGIS in PyScripter, I have followed the tutorial provided in QGIS tutorial: IDE settings for writing and debugging plugins. I have created the bat file as follows:

SET OSGEO4W_ROOT=C:\OSGeo4W
SET QGISNAME=qgis
SET QGIS=%OSGEO4W_ROOT%\apps\%QGISNAME%
SET QGIS_PREFIX_PATH=%QGIS%
SET PyScripter="C:\Program Files\PyScripter\PyScripter.exe"

CALL %OSGEO4W_ROOT%\bin\o4w_env.bat

SET PATH=%PATH%;%QGIS%\bin
SET PYTHONPATH=%QGIS%\python;%PYTHONPATH%

REM PYTHONHOME: %OSGEO4W_ROOT%\bin
REM PYTHONPATH: %OSGEO4W_ROOT%\apps\Python37\lib;%OSGEO4W_ROOT%\apps\qgis\python;%OSGEO4W_ROOT%\apps\Python37\Lib\site-packages

start "script" /B %PyScripter% %*"

The error message appears again:ModuleNotFoundError: No module named 'qgis'.

Note: I am using QGIS 3.10 and python 37.

2 Answers 2

1

You can use the qgis batch file as a template.

@echo off
SET QGISNAME=qgis
SET PyScripter="C:\Program Files\PyScripter\PyScripter.exe" 

call "%~dp0\o4w_env.bat" 
call qt5_env.bat 
call py3_env.bat 

path %OSGEO4W_ROOT%\apps\%QGISNAME%\bin;%PATH% 
set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/%QGISNAME%
set GDAL_FILENAME_IS_UTF8=YES 
rem Set VSI cache to be used as buffer, see #6448 
set VSI_CACHE=TRUE 
set VSI_CACHE_SIZE=1000000 
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\%QGISNAME%\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins 
set PYTHONPATH=%OSGEO4W_ROOT%\apps\%QGISNAME%\python;%PYTHONPATH%
start "PyScripter" "%PyScripter%" %*
3
  • Thanks, @Andreas for your reply, I used also this one but it didn't work, the solution is using Eclipse, defining the packages in its preferences and all done
    – Alloylo
    Commented Nov 29, 2019 at 9:37
  • 1
    Oh, i just missed a line to set the pythonpath, as you did in your batch file, edited that it works for me. For the case that anyone else is searching for a solution with PyScripter, could you please check my editet batch file? Commented Nov 29, 2019 at 10:11
  • it did not work I had set the python path and OSGEO$W_ROOT but it didnot work
    – Alloylo
    Commented Nov 30, 2019 at 10:08
0

I have found the solution: Just use Eclipse IDE and add the Pyqgis packages to the PyDev,and it will works!!!

1
  • Be aware that if you want to develop QGIS-Standalone applications or even QGIS-Plugins with python, you'll need parts of that environment, set in the batch files. Commented Nov 29, 2019 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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