6

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 Files\QGIS 3.2

call "%OSGEO4W_ROOT%"\bin\o4w_env
call "%OSGEO4W_ROOT%"\apps\grass\grass-7.4.1\etc\env.bat
@echo off
path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin
path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-7.4.1\lib
path %PATH%;%OSGEO4W_ROOT%\apps\Qt5\bin
path %PATH%;%OSGEO4W_ROOT%\apps\Python36\Scripts

set PYTHONPATH=%PYTHONPATH%;%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python36


SET PYCHARM="C:\Program Files\JetBrains\PyCharm 2018.1.4\bin\pycharm.exe
start "PyCharm aware of QGIS" /B %PYCHARM% %*

Error is:

  File "C:\PROGRA~1\QGIS3~1.2\apps\Python36\lib\site.py", line 177
    file=sys.stderr)
        ^
SyntaxError: invalid syntax
Taras
  • 32,823
  • 4
  • 66
  • 137
jessie jes
  • 1,061
  • 8
  • 21

2 Answers2

1

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

SET OSGEO4W_ROOT=C:\Program Files\QGIS 3.2

try setting it to your OSGeo4W64 root folder like below:

SET OSGEO4W_ROOT=C:\OSGeo4W64
cm1
  • 2,280
  • 14
  • 26
0

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?

Comrade Che
  • 7,091
  • 27
  • 58