[Qgis-developer] Compiling ui files with custom widgets creates wrong imports

Denis Rouzaud denis.rouzaud at gmail.com
Mon Sep 21 22:05:57 PDT 2015


Hi all,


The path that must be specified as PYTHONPATH is
QGIS_PREFIX_PATH/share/qgis/python

All the custom widgets have their classes in qgis gui. Therefore, you
just need to add the QGIS python path to PYTHONPATH to be able to define
properly their import.

As Jürgen said there might be several versions of QGIS installed (i.e.
different versions of the custom widgets library), hence the PYTHONPATH
can't be set automatically.

Denis



On 09/19/2015 03:16 PM, Lauri Kajan wrote:
> Hi Jürgen!
> 
> I think that this can't be fixed by just setting the PYTHONPATH. 
> 
> If I have understood right the problem is that PyQt and its uic module
> can't find qgis_customwidgets.py or better said
> 'qgis-dev\python\PyQt4\uic\widget-plugins' directory because it is not
> told to do so. It is not that some module can't be imported because it
> is not in pythonpath. Please correct me if I'm wrong.
> 
> Directories that are searched for widget plugins by PyQt4 are defined in
> uic.widgetPluginPath. I have not found any environment variable where
> this list can be altered.
> After I appended
> "C:\OSGeo4W64\apps\qgis-dev\python\PyQt4\uic\widget-plugins" to the
> widgetPluginPath list I'm able to use uic.loadUiType function inside
> python. Still that doesn't solve the problem with pyuic4 because
> widgetPluginPath can't be set externally.
> 
> 
> -Lauri
> 
> 
> 
> On Sat, Sep 19, 2015 at 12:47 PM, Jürgen E. <jef at norbit.de
> <mailto:jef at norbit.de>> wrote:
> 
>     Hi Lauri,
> 
>     On Sat, 19. Sep 2015 at 12:11:11 +0300, Lauri Kajan wrote:
>     > The actual problem might be that
>     > C:\OSGeo4W64\apps\qgis-dev\python\PyQt4\uic\widget-plugins\qgis_customwidgets.py
>     > file is not found by pyuic4.
>     > After I copied that file
>     > to C:\OSGeo4W64\apps\Python27\Lib\site-packages\PyQt4\uic\widget-plugins
>     > everything works ok.
>     >
>     > Is this a osgeo4w bug or could this be fixed by us?
> 
>     > Should the qgis postinstall bat copy qgis_customwidgets.py file to the
>     > right place?
> 
>     No, qgis-dev might not be the only installed version - so you have
>     to setup the
>     PYTHONPATH to use the version you target.
> 
> 
>     Jürgen
> 
>     --
>     Jürgen E. Fischer           norBIT GmbH             Tel.
>     +49-4931-918175-31 <tel:%2B49-4931-918175-31>
>     Dipl.-Inf. (FH)             Rheinstraße 13          Fax.
>     +49-4931-918175-50 <tel:%2B49-4931-918175-50>
>     Software Engineer           D-26506 Norden           
>      http://www.norbit.de
>     QGIS release manager (PSC)  Germany                    IRC: jef on
>     FreeNode
> 
>     _______________________________________________
>     Qgis-developer mailing list
>     Qgis-developer at lists.osgeo.org <mailto:Qgis-developer at lists.osgeo.org>
>     http://lists.osgeo.org/mailman/listinfo/qgis-developer
> 
> 
> 
> 
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
> 


More information about the Qgis-developer mailing list