TransWikia.com

PyQGIS standalone script using QGIS 3.2

Geographic Information Systems Asked by jessie jes on February 21, 2021

I want to work with PyQGIS Python 3 using QGIS 3.2 standalone install. I created a simple batch file to work with PyQGIS but I have some errors.

Here’s the batch file:

@echo off
SET OSGEO4W_ROOT=C:Program FilesQGIS 3.2

call "%OSGEO4W_ROOT%"bino4w_env
call "%OSGEO4W_ROOT%"appsgrassgrass-7.4.1etcenv.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%appsqgisbin
path %PATH%;%OSGEO4W_ROOT%appsgrassgrass-7.4.1lib
path %PATH%;%OSGEO4W_ROOT%appsQt5bin
path %PATH%;%OSGEO4W_ROOT%appsPython36Scripts

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%appsqgispython
set PYTHONHOME=%OSGEO4W_ROOT%appsPython36


SET PYCHARM="C:Program FilesJetBrainsPyCharm 2018.1.4binpycharm.exe
start "PyCharm aware of QGIS" /B %PYCHARM% %*

Error is:

  File "C:PROGRA~1QGIS3~1.2appsPython36libsite.py", line 177
    file=sys.stderr)
        ^
SyntaxError: invalid syntax

2 Answers

The problem may be caused by incorrect PyCharm setup, check this answer: Why does QGIS 3.2 "native:extractvertices" algorithm not work properly in standalone script?

Answered by Comrade Che on February 21, 2021

Jessie, I suspect there may be a problem with this line in your batch file:

SET OSGEO4W_ROOT=C:Program FilesQGIS 3.2

try setting it to your OSGeo4W64 root folder like below:

SET OSGEO4W_ROOT=C:OSGeo4W64

Answered by cm1 on February 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP