5

I am trying to run v.clean through GRASS 7.6.1 using QGIS 3.10 and Python 3.7 on a line shapefile. I have tried with the output both saving to a file location and as a temporary file, and the error is the same.

Input Parameters:

{ '-b' : False, '-c' : False, 'GRASS_MIN_AREA_PARAMETER' : 0.0001, 
'GRASS_OUTPUT_TYPE_PARAMETER' : 2, 'GRASS_REGION_PARAMETER' : None, 
'GRASS_SNAP_TOLERANCE_PARAMETER' : -1, 'GRASS_VECTOR_DSCO' : '', 
'GRASS_VECTOR_EXPORT_NOCAT' : False, 'GRASS_VECTOR_LCO' : '', 'error' : 
'TEMPORARY_OUTPUT', 'input' : 'C:/file.shp', 'output' : 'TEMPORARY_OUTPUT', 'threshold' : 
'1', 'tool' : [1], 'type' : [1] }

Error message:

File "C:\Python37\Lib\site.py", line 177
file=sys.stderr)
^
SyntaxError: invalid syntax
Press any key to continue . . .
File "C:\Python37\Lib\site.py", line 177
file=sys.stderr)
^
SyntaxError: invalid syntax
Press any key to continue . . .
Execution completed in 2.32 seconds
Results:
{'error': <QgsProcessingOutputLayerDefinition {'sink':TEMPORARY_OUTPUT, 'createOptions': {'fileEncoding': 'System'}}>,
'output': <QgsProcessingOutputLayerDefinition {'sink':TEMPORARY_OUTPUT, 'createOptions': {'fileEncoding': 'System'}}>}

The closest answer I could find was an issue with using Python 2 instead of 3, but I am definitely using Python 3.7. I have had issues with that in the past, and made sure to run this both with my regular file names and renaming the path for 2.7 to be sure it's not accidentally using Python 2.

0
+50

I haven't used GRASS before, but the python error message looks familiar, at times when I've used incompatible scripts (e.g. something written for 2.x, but run in 3.x, or vice-versa). I know you've mentioned the discrepancy in your post, but have you tried running the same operation using 2.x? The python installation may have added env variables that automatically run a particular python installation from one of the install directories (i.e. 2.x install or 3.x install). You may have to explicitly include the full path to the python version you'd like to target (e.g. c:\Python27\python.exe).

| improve this answer | |
  • 1
    Running in 2.7 worked - had to force 2.7 by changing the path to 3.7 and then it worked to run through QGIS. – jyingling Dec 3 '19 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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