<div class="gmail_quote">On Tue, Oct 26, 2010 at 3:22 AM, Martin Dobias <span dir="ltr">&lt;<a href="http://wonder.sk">wonder.sk</a>@<a href="http://gmail.com">gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div></div><div class="h5">On Tue, Oct 19, 2010 at 4:45 PM, Jitendra kumar<br>
&lt;<a href="mailto:jitendra.harlalka@gmail.com">jitendra.harlalka@gmail.com</a>&gt; wrote:<br>
&gt; Hello all,<br>
&gt;     I am new to Python binding for QGIS. I have been having problem in<br>
&gt; getting a Vector Layer to be loaded. I typed the following on python<br>
&gt; console:<br>
&gt;<br>
&gt;&gt;&gt;&gt; from qgis.core import *<br>
&gt;&gt;&gt;&gt; layer=QgsVectorLayer(&quot;/path/to/shape/file.shp&quot;,&quot;layer&quot;,&quot;ogr&quot;)<br>
&gt; Failed to load<br>
&gt;<br>
&gt; The output is &quot;Failed to load&quot; which isn&#39;t very helpful and doesn&#39;t specify<br>
&gt; the cause. I am not sure what is the problem. I have confirmed that filepath<br>
&gt; is correct and the shp file can be opened in QGIS. I would appreciate if<br>
&gt; someone could help me solve the problem.<br>
<br>
</div></div>Are you using python console within QGIS or do you open the python<br>
interpreter from a terminal? In the latter case, you would have to<br>
initialize qgis core library first by calling<br>
QgsApplication.initQgis() otherwise it will not find the data<br>
providers necessary for opening vector layers.<br></blockquote><div><br>@Martin,<br>I am glad you replied. I was actually using python interpreter from terminal. And, now I understand why I couldn&#39;t get it to work. It works fine now. <br>

<br>It would be great if someone could make the error message more helpful. &quot;Failed to load&quot; wasn&#39;t very helpful ;)<br><br>Thanks once again.<br></div><div><br>Regards,<br>Jitendra <br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


<a href="http://www.qgis.org/pyqgis-cookbook/intro.html#using-pyqgis-in-custom-application" target="_blank">http://www.qgis.org/pyqgis-cookbook/intro.html#using-pyqgis-in-custom-application</a><br>
<font color="#888888"><br>
Martin<br>
</font></blockquote></div><br>