<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Dear all,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On the standalone 64-bit QGIS Wien version on Win7 I was able to run the following code using Python in the OSGeo4W Shell:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>import os<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>from PyQt4.QtCore import *<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>from PyQt4.QtGui import *<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>from qgis.core import *<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>from qgis.gui import *<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>qgis_prefix = os.getenv("QGIS_PREFIX_PATH")<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>QgsApplication.setPrefixPath(qgis_prefix, True)<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>QgsApplication.initQgis()<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>inshpfile = "test.shp"<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>layer = QgsVectorLayer(inshpfile, "shapefile", "ogr")<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'># do stuff with layer<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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):<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>@echo off<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>rem Root OSGEO4W home dir to the same directory this script exists in<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>call "%~dp0\bin\o4w_env.bat"<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console";background:yellow;mso-highlight:yellow'>set PYTHONPATH=C:\Program Files\QGIS Lyon\apps\qgis\python<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console";background:yellow;mso-highlight:yellow'>set PATH=C:\Program Files\QGIS Lyon\apps\qgis\bin;%PATH%<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console";background:yellow;mso-highlight:yellow'>set QGIS_PREFIX_PATH=C:\Program Files\QGIS Lyon\apps\qgis</span><span style='font-size:9.0pt;font-family:"Lucida Console"'><o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>rem List available o4w programs<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>rem but only if osgeo4w called without parameters<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>@echo on<o:p></o:p></span></p><p class=MsoNormal style='margin-left:36.0pt'><span style='font-size:9.0pt;font-family:"Lucida Console"'>@if [%1]==[] (cmd.exe /k o-help) else (cmd /c "%*")<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.<o:p></o:p></p><p class=MsoNormal>Can someone maybe reproduce the crash? And if so, any idea what might be the cause?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Kind regards,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Jelmer Oosthoek<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Ps. Attached are test.py and test.shp.<o:p></o:p></p></div></body></html>