<div dir="ltr">Hi Denis,<div><br></div><div>Unfortunately this seems not to be enough.</div><div>If pythonpath is set pyuic4 still produces wrong import.</div><div><br></div><div>Here's my environment and command to compile ui file with QgsMapLayerComboBox.</div><div>------------------</div><div><div>C:\OSGeo4W64>echo %PATH%</div><div>C:\OSGEO4~1\apps\qgis-dev\bin;C:\OSGEO4~1\apps\Python27\Scripts;C:\OSGEO4~1\bin;</div><div>C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\WBem;C:\OSGEO4~1\apps\msys\bin</div><div><br></div><div>C:\OSGeo4W64>echo %PYTHONPATH%</div><div>C:\OSGEO4~1\apps\qgis-dev\python</div><div><br></div><div>C:\OSGeo4W64>pyuic4 test_widget.ui -o test_widget.py</div></div><div>-----------------</div><div><br></div><div>In the compiled test_widget.py there's still a line:</div><div>from qgsmaplayercombobox import QgsMapLayerComboBox<br></div><div><br></div><div><br></div><div>Paths should be set correctly because importing qgis.gui works ok from python started from the same environment.</div><div><br></div><div><br></div><div>PyQt and pyuic4 reads custom witget definitions from C:\OSGeo4W64\apps\Python27\Lib\site-packages\PyQt4\uic\widget-plugins.</div><div>I think that PyQt is not aware of C:\OSGeo4W64\apps\qgis-dev\python\PyQt4\uic\widget-plugins folder.</div><div><br></div><div><br></div><div>This is not a problem of only pyuic4.</div><div>Also all plugins that use custom qgis widgets and try to import ui files directly in their code using the uic.loadUiType() function crashes on windows!</div><div><br></div><div><br></div><div><br></div><div>-Lauri</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 22, 2015 at 8:05 AM, Denis Rouzaud <span dir="ltr"><<a href="mailto:denis.rouzaud@gmail.com" target="_blank">denis.rouzaud@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
<br>
The path that must be specified as PYTHONPATH is<br>
QGIS_PREFIX_PATH/share/qgis/python<br>
<br>
All the custom widgets have their classes in qgis gui. Therefore, you<br>
just need to add the QGIS python path to PYTHONPATH to be able to define<br>
properly their import.<br>
<br>
As Jürgen said there might be several versions of QGIS installed (i.e.<br>
different versions of the custom widgets library), hence the PYTHONPATH<br>
can't be set automatically.<br>
<br>
Denis<br>
<span class=""><br>
<br>
<br>
On 09/19/2015 03:16 PM, Lauri Kajan wrote:<br>
> Hi Jürgen!<br>
><br>
> I think that this can't be fixed by just setting the PYTHONPATH.<br>
><br>
> If I have understood right the problem is that PyQt and its uic module<br>
> can't find qgis_customwidgets.py or better said<br>
> 'qgis-dev\python\PyQt4\uic\widget-plugins' directory because it is not<br>
> told to do so. It is not that some module can't be imported because it<br>
> is not in pythonpath. Please correct me if I'm wrong.<br>
><br>
> Directories that are searched for widget plugins by PyQt4 are defined in<br>
> uic.widgetPluginPath. I have not found any environment variable where<br>
> this list can be altered.<br>
> After I appended<br>
> "C:\OSGeo4W64\apps\qgis-dev\python\PyQt4\uic\widget-plugins" to the<br>
> widgetPluginPath list I'm able to use uic.loadUiType function inside<br>
> python. Still that doesn't solve the problem with pyuic4 because<br>
> widgetPluginPath can't be set externally.<br>
><br>
><br>
> -Lauri<br>
><br>
><br>
><br>
> On Sat, Sep 19, 2015 at 12:47 PM, Jürgen E. <<a href="mailto:jef@norbit.de">jef@norbit.de</a><br>
</span><span class="">> <mailto:<a href="mailto:jef@norbit.de">jef@norbit.de</a>>> wrote:<br>
><br>
> Hi Lauri,<br>
><br>
> On Sat, 19. Sep 2015 at 12:11:11 +0300, Lauri Kajan wrote:<br>
> > The actual problem might be that<br>
> > C:\OSGeo4W64\apps\qgis-dev\python\PyQt4\uic\widget-plugins\qgis_customwidgets.py<br>
> > file is not found by pyuic4.<br>
> > After I copied that file<br>
> > to C:\OSGeo4W64\apps\Python27\Lib\site-packages\PyQt4\uic\widget-plugins<br>
> > everything works ok.<br>
> ><br>
> > Is this a osgeo4w bug or could this be fixed by us?<br>
><br>
> > Should the qgis postinstall bat copy qgis_customwidgets.py file to the<br>
> > right place?<br>
><br>
> No, qgis-dev might not be the only installed version - so you have<br>
> to setup the<br>
> PYTHONPATH to use the version you target.<br>
><br>
><br>
> Jürgen<br>
><br>
> --<br>
> Jürgen E. Fischer norBIT GmbH Tel.<br>
</span>> <a href="tel:%2B49-4931-918175-31" value="+49493191817531">+49-4931-918175-31</a> <tel:%2B49-4931-918175-31><br>
<span class="">> Dipl.-Inf. (FH) Rheinstraße 13 Fax.<br>
</span>> <a href="tel:%2B49-4931-918175-50" value="+49493191817550">+49-4931-918175-50</a> <tel:%2B49-4931-918175-50><br>
<span class="">> Software Engineer D-26506 Norden<br>
> <a href="http://www.norbit.de" rel="noreferrer" target="_blank">http://www.norbit.de</a><br>
> QGIS release manager (PSC) Germany IRC: jef on<br>
> FreeNode<br>
><br>
> _______________________________________________<br>
> Qgis-developer mailing list<br>
</span>> <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a> <mailto:<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a>><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
<div class="HOEnZb"><div class="h5">><br>
><br>
><br>
><br>
> _______________________________________________<br>
> Qgis-developer mailing list<br>
> <a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
><br>
</div></div></blockquote></div><br></div>