[Qgis-developer] QgsVectorLayer
Jelmer Oosthoek
jhpoosthoek at gispla.net
Fri Nov 20 02:24:07 PST 2015
Dear all,
On the standalone 64-bit QGIS Wien version on Win7 I was able to run the
following code using Python in the OSGeo4W Shell:
import os
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
qgis_prefix = os.getenv("QGIS_PREFIX_PATH")
QgsApplication.setPrefixPath(qgis_prefix, True)
QgsApplication.initQgis()
inshpfile = "test.shp"
layer = QgsVectorLayer(inshpfile, "shapefile", "ogr")
# do stuff with layer
As a prerequisite I had to add the following three yellow lines to
OSGeo4W.bat first before running the shell (with Lyon here of course Wien):
@echo off
rem Root OSGEO4W home dir to the same directory this script exists in
call "%~dp0\bin\o4w_env.bat"
set PYTHONPATH=C:\Program Files\QGIS Lyon\apps\qgis\python
set PATH=C:\Program Files\QGIS Lyon\apps\qgis\bin;%PATH%
set QGIS_PREFIX_PATH=C:\Program Files\QGIS Lyon\apps\qgis
rem List available o4w programs
rem but only if osgeo4w called without parameters
@echo on
@if [%1]==[] (cmd.exe /k o-help) else (cmd /c "%*")
But since I installed QGIS Pisa and then Lyon, Python crashes at the layer =
QgsVectorLayer(.) line, whether or not I have an actual test.shp available.
The module which causes the crash is QtCore4.dll.
Can someone maybe reproduce the crash? And if so, any idea what might be the
cause?
Kind regards,
Jelmer Oosthoek
Ps. Attached are test.py and test.shp.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151120/5fe0e298/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.zip
Type: application/x-zip-compressed
Size: 1819 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151120/5fe0e298/attachment.bin>
More information about the Qgis-developer
mailing list