*Running QGIS 3.6, GRASS 7.6; have both Python 2 and 3

I'm trying to run a GRASS algorithm in QGIS, and none of the GRASS tools are working. GRASS also isn't working in the standalone version. I have tried both QGIS and QGIS with GRASS.

I tried changing the name of my Python 3.7 path as that has caused issues in the past, and got this error when running in QGIS:

This algorithm cannot be run :-( The specified GRASS 7 folder "C:\Program Files\QGIS 3.6\bin\bin" does not contain a valid set of GRASS 7 modules. Please, go to the Processing settings dialog, and check that the GRASS 7 folder is correctly configured

When I run GRASS independently (for 7.4 and 7.6), the command line opens with the following error:

File "C:\Python37\Lib\site.py", line 177
SyntaxError: invalid syntax
Press any key to continue . . .

Running grass within QGIS (v.clean tool):

The following layers were not correctly generated. [....] You can check the 'Log Messages Panel' in QGIS main window to find more information about the execution of the algorithm.

There is nothing substantial in Log Messages, but looking through the GRASS log I found the same thing I was getting when trying to run GRASS standalone:

File "C:\Python37\Lib\site.py", line 177
SyntaxError: invalid syntax
Press any key to continue . . .

I checked my processing options: GRASS is activated and the docs are in the proper location.

I also tried looking for any errors around the 'syntax error' in Python37\Lib\site.py, as well as a couple of GRASS .bat files, but I don't know enough about using GRASS to actually tell if anything is wrong.

  • are you sure QGIS and GRASS can run on python 3.7? Python 2.7 and Python 3.7 are very much imcompatible
    – Paul H
    Mar 26, 2019 at 20:55
  • @PaulH I have Python 2.7 installed but I'm not familiar enough with GRASS to know how/what to change. I agree, though - it looks like GRASS is using 3.7 for some reason. I tried changing the 3.7 file path to force using 2.7 but got the first error in my post.
    – jyingling
    Mar 28, 2019 at 13:31

2 Answers 2


Note that GRASS GIS 7.4 and 7.6 only work with Python 2. We are close to a full update to Python 3 which is done in the current development version GRASS GIS 7.7 (to become 7.8 stable then).

If possible for you, consider to update to GRASS GIS 7.7 (AFAIK it is available in the OSGeo4W installer, under development section).

Edit Sep 2019:

GRASS GIS 7.8.0 with Python 3 support as been released:

  • Thanks - I have Python 2.7 installed, what should I change so that GRASS isn't trying to use 3.7?
    – jyingling
    Mar 28, 2019 at 21:58
  • On Windows I don't really know - perhaps update the search PATH to switch the order of searching? I am more familiar with Linux...
    – markusN
    Mar 29, 2019 at 19:19

I ran into the same problem and solved it by adding the following line to my PyCharm startup file:

call "%OSGEO4W_ROOT%\apps\grass\grass78\etc\env.bat"

The entire .cmd file contains this:

@ECHO off


call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
call "%OSGEO4W_ROOT%\bin\py3_env.bat"
call "%OSGEO4W_ROOT%\apps\grass\grass78\etc\env.bat"

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


set VSI_CACHE_SIZE=1000000
set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins

SET PYCHARM="C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.1\bin\pycharm64.exe"

set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python
set PYTHONHOME=%OSGEO4W_ROOT%\apps\Python37
set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python37\lib\site-packages;%PYTHONPATH%

set QT_QPA_PLATFORM_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\Qt5\plugins\platforms

start "PyCharm aware of QGIS" /B %PYCHARM% %*

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.