Skip to main content
added 119 characters in body
Source Link
user123480
  • 119
  • 1
  • 11

When I try to execute this code:

 from qgis.core import *

 QgsApplication.setPrefixPath("/usr/lib/qgis", True)
 app = QgsApplication([], True)
 app.initQgis()


 layer = QgsVectorLayer('/home/city.shp',"p", "ogr")
 QgsProject.instance().addMapLayers([layer])

 shp_path = '/home/points.shp'
 csv_path = '/home/a.csv'
 tag_save_as_shp = '/home/sep.shp'

 layerInput = QgsVectorLayer(shp_path, "cells", "ogr")
 csvInput = QgsVectorLayer(csv_path, "Table_csv", "ogr")
 QgsProject.instance().addMapLayer(layerInput, False)
 QgsProject.instance().addMapLayer(csvInput, False)
 # joining csv with shp
 csvField = 'Square-ID'
 shpField = 'cellId'
 joinObject = QgsVectorLayerJoinInfo()
 joinObject.setJoinFieldName(csvField)
 joinObject.setTargetFieldName(shpField)
 joinObject.setJoinLayerId(csvInput.id())
 joinObject.setUsingMemoryCache(True)
 joinObject.setJoinLayer(csvInput)
 joinObject.setPrefix('')
 layerInput.addJoin(joinObject)
   QgsVectorFileWriter.writeAsVectorFormat(layerInput,tag_save_as_shp,"CP120",layerInput.crs(),"ESRI Shapefile")

I get an error in PyCharm:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

But in the python console in QGIS everything works fine. Also, this code worked before two weeks from PyCharm also. I read that is about some memory violation, but I don't understand it. :/

UPDATE: If I deleted the QgsVectorFileWriter line, everything is ok. So I have problem when I try to make output..

When I try to execute this code:

 from qgis.core import *

 QgsApplication.setPrefixPath("/usr/lib/qgis", True)
 app = QgsApplication([], True)
 app.initQgis()


 layer = QgsVectorLayer('/home/city.shp',"p", "ogr")
 QgsProject.instance().addMapLayers([layer])

 shp_path = '/home/points.shp'
 csv_path = '/home/a.csv'
 tag_save_as_shp = '/home/sep.shp'

 layerInput = QgsVectorLayer(shp_path, "cells", "ogr")
 csvInput = QgsVectorLayer(csv_path, "Table_csv", "ogr")
 QgsProject.instance().addMapLayer(layerInput, False)
 QgsProject.instance().addMapLayer(csvInput, False)
 # joining csv with shp
 csvField = 'Square-ID'
 shpField = 'cellId'
 joinObject = QgsVectorLayerJoinInfo()
 joinObject.setJoinFieldName(csvField)
 joinObject.setTargetFieldName(shpField)
 joinObject.setJoinLayerId(csvInput.id())
 joinObject.setUsingMemoryCache(True)
 joinObject.setJoinLayer(csvInput)
 joinObject.setPrefix('')
 layerInput.addJoin(joinObject)
   QgsVectorFileWriter.writeAsVectorFormat(layerInput,tag_save_as_shp,"CP120",layerInput.crs(),"ESRI Shapefile")

I get an error in PyCharm:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

But in the python console in QGIS everything works fine. Also, this code worked before two weeks from PyCharm also. I read that is about some memory violation, but I don't understand it. :/

When I try to execute this code:

 from qgis.core import *

 QgsApplication.setPrefixPath("/usr/lib/qgis", True)
 app = QgsApplication([], True)
 app.initQgis()


 layer = QgsVectorLayer('/home/city.shp',"p", "ogr")
 QgsProject.instance().addMapLayers([layer])

 shp_path = '/home/points.shp'
 csv_path = '/home/a.csv'
 tag_save_as_shp = '/home/sep.shp'

 layerInput = QgsVectorLayer(shp_path, "cells", "ogr")
 csvInput = QgsVectorLayer(csv_path, "Table_csv", "ogr")
 QgsProject.instance().addMapLayer(layerInput, False)
 QgsProject.instance().addMapLayer(csvInput, False)
 # joining csv with shp
 csvField = 'Square-ID'
 shpField = 'cellId'
 joinObject = QgsVectorLayerJoinInfo()
 joinObject.setJoinFieldName(csvField)
 joinObject.setTargetFieldName(shpField)
 joinObject.setJoinLayerId(csvInput.id())
 joinObject.setUsingMemoryCache(True)
 joinObject.setJoinLayer(csvInput)
 joinObject.setPrefix('')
 layerInput.addJoin(joinObject)
   QgsVectorFileWriter.writeAsVectorFormat(layerInput,tag_save_as_shp,"CP120",layerInput.crs(),"ESRI Shapefile")

I get an error in PyCharm:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

But in the python console in QGIS everything works fine. Also, this code worked before two weeks from PyCharm also. I read that is about some memory violation, but I don't understand it. :/

UPDATE: If I deleted the QgsVectorFileWriter line, everything is ok. So I have problem when I try to make output..

Source Link
user123480
  • 119
  • 1
  • 11

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV) - PyQGIS in PyCharm

When I try to execute this code:

 from qgis.core import *

 QgsApplication.setPrefixPath("/usr/lib/qgis", True)
 app = QgsApplication([], True)
 app.initQgis()


 layer = QgsVectorLayer('/home/city.shp',"p", "ogr")
 QgsProject.instance().addMapLayers([layer])

 shp_path = '/home/points.shp'
 csv_path = '/home/a.csv'
 tag_save_as_shp = '/home/sep.shp'

 layerInput = QgsVectorLayer(shp_path, "cells", "ogr")
 csvInput = QgsVectorLayer(csv_path, "Table_csv", "ogr")
 QgsProject.instance().addMapLayer(layerInput, False)
 QgsProject.instance().addMapLayer(csvInput, False)
 # joining csv with shp
 csvField = 'Square-ID'
 shpField = 'cellId'
 joinObject = QgsVectorLayerJoinInfo()
 joinObject.setJoinFieldName(csvField)
 joinObject.setTargetFieldName(shpField)
 joinObject.setJoinLayerId(csvInput.id())
 joinObject.setUsingMemoryCache(True)
 joinObject.setJoinLayer(csvInput)
 joinObject.setPrefix('')
 layerInput.addJoin(joinObject)
   QgsVectorFileWriter.writeAsVectorFormat(layerInput,tag_save_as_shp,"CP120",layerInput.crs(),"ESRI Shapefile")

I get an error in PyCharm:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

But in the python console in QGIS everything works fine. Also, this code worked before two weeks from PyCharm also. I read that is about some memory violation, but I don't understand it. :/