[QGIS-Developer] PyQgis Standalone app from 3.4 to 3.16

2022-10-03 Thread PIERRE Sylvain via QGIS-Developer
Hi devs,

I'm porting a PyQgis standalone app from 3.4 to 3.16 api.
I get an error with the new 3.16 app
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: 

The most visible change I noticed is python 3.7 to 3.9. Is there any impact on 
PyQt5 bindings ?  With python 3.7 there was a C:\Program Files\QGIS 
3.4\apps\Python37\sip directory which is missing with python 3.9.

Here is my app env variables
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = r'C:\Program Files\QGIS 
3.16.16\apps\Qt5\plugins'
os.environ['PATH'] += r';C:\Program Files\QGIS 3.16.16\apps\qgis-ltr;C:\Program 
Files\QGIS 3.16.16\apps\qgis\bin;C:\Program Files\QGIS 3.16.16\apps\Qt5\bin'
os.environ['QGIS_PREFIX_PATH'] = r'C:\Program Files\QGIS 3.16.16\apps\qgis-ltr'
os.environ['GDAL_DATA'] = r'C:\Program Files\QGIS 3.16.16\share\gdal'
os.environ['PROJ_LIB'] = r'C:\Program Files\QGIS 3.16.16\share\proj'

os.environ['GDAL_DRIVER_PATH'] = r'C:\Program Files\QGIS 
3.16.16\bin\gdalplugins'
os.environ['QT_PLUGIN_PATH'] = r'C:\Program Files\QGIS 
3.16.16\apps\qgis\qtplugins;C:\Program Files\QGIS 3.16.16\apps\qt5\plugins'

Did I miss something ?

Thanks

[cid:image002.jpg@01D8D739.62F6AA70]
Sylvain PIERRE
Chef de projet système d'information
Direction des Systèmes d'Information et du Développement Numérique
Service Projets et Ingénierie Numérique
Collectivité européenne d'Alsace
Tél : 03 88 76 68 88
sylvain.pie...@alsace.eu
www.alsace.eu
[facebook] [twitter] 
  [insta] 


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] import 3d or _3d in python?

2022-10-03 Thread Andrea Giudiceandrea via QGIS-Developer

Il 03/10/2022 09:19, Raymond Nijssen via QGIS-Developer ha scritto:
I know, but my script is not running in the console. It is part of a 
plugin, so I need to do the import. Would be handy if the 
documentation tells me how to do it.


Yes, I understood that. I just wanted to point out that QGIS itself 
imports the 3d library using qgis._3d, so it should be the correct 
module name to use.


Best regards.

Andrea
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] import 3d or _3d in python?

2022-10-03 Thread Martin Dobias via QGIS-Developer
Hi Raymond

The general idea is that for every PyQGIS module (e.g. "core") there is a
compiled python module (e.g. _core.so) and a directory acting as a module
("core") which imports the compiled module and adds some extra
functionality (docstrings and more). So normally one wants to use import
qgis.core instead of qgis._core.

Now with the 3d module things are not so great, because "3d" is not a valid
module name because of the leading digit, so import qgis.3d simply won't
work. There are some ways to work it around [1], but I wouldn't recommend
using them. But as stated earlier, importing qgis._3d should generally do
the job.

It is probably worth creating a ticket to address this, but I am not sure
how to best fix it - probably the whole module should be renamed so avoid
the leading digit - e.g. "threed"

[1]
https://stackoverflow.com/questions/9090079/in-python-how-to-import-filename-starts-with-a-number

Cheers
Martin


On Mon, Oct 3, 2022 at 8:58 AM Raymond Nijssen via QGIS-Developer <
qgis-developer@lists.osgeo.org> wrote:

>
> While trying to import a 3D class in a python script, I found out that
> the code in the pyqgis docs is not working (for me):
>
> from qgis.3d import QgsLayoutItem3DMap
>
>
> Instead I need to add an underscore for the 3d module name:
>
> from qgis._3d import QgsLayoutItem3DMap
>
>
>
> Should this be fixed in the documentation? I'm not all sure, cause when
> trying to fix it, I found this related commit:
>
>
> https://github.com/qgis/pyqgis/commit/1ac564790aa0b7abbd003c04d07358d8e4f14493
>
>
>
> This is the page in the docs:
> https://qgis.org/pyqgis/master/3d/QgsLayoutItem3DMap.html
>
>
> Should I make an issue? It took me a while to figure out that _3d solution.
>
> Cheers,
> Raymond
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] import 3d or _3d in python?

2022-10-03 Thread Raymond Nijssen via QGIS-Developer

Hi Andrea,

I know, but my script is not running in the console. It is part of a 
plugin, so I need to do the import. Would be handy if the documentation 
tells me how to do it.


Kind regards,
Raymond


On 03-10-2022 09:02, Andrea Giudiceandrea via QGIS-Developer wrote:

Il 03/10/2022 08:57, Raymond Nijssen via QGIS-Developer ha scritto:


Instead I need to add an underscore for the 3d module name:

from qgis._3d import QgsLayoutItem3DMap


In the Python console, the 3d library is automatically imported (if QGIS 
is compiled with 3d support) with:


from qgis._3d import *

See: 
https://github.com/qgis/QGIS/blob/95e00c50d219b39b2571dd6bff59a1393deb9b6a/python/console/console_sci.py#L59 



Best regards.

Andrea Giudiceandrea
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] import 3d or _3d in python?

2022-10-03 Thread Andrea Giudiceandrea via QGIS-Developer

Il 03/10/2022 08:57, Raymond Nijssen via QGIS-Developer ha scritto:


Instead I need to add an underscore for the 3d module name:

from qgis._3d import QgsLayoutItem3DMap


In the Python console, the 3d library is automatically imported (if QGIS 
is compiled with 3d support) with:


from qgis._3d import *

See: 
https://github.com/qgis/QGIS/blob/95e00c50d219b39b2571dd6bff59a1393deb9b6a/python/console/console_sci.py#L59


Best regards.

Andrea Giudiceandrea
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


[QGIS-Developer] import 3d or _3d in python?

2022-10-03 Thread Raymond Nijssen via QGIS-Developer



While trying to import a 3D class in a python script, I found out that 
the code in the pyqgis docs is not working (for me):


from qgis.3d import QgsLayoutItem3DMap


Instead I need to add an underscore for the 3d module name:

from qgis._3d import QgsLayoutItem3DMap



Should this be fixed in the documentation? I'm not all sure, cause when 
trying to fix it, I found this related commit:


https://github.com/qgis/pyqgis/commit/1ac564790aa0b7abbd003c04d07358d8e4f14493



This is the page in the docs:
https://qgis.org/pyqgis/master/3d/QgsLayoutItem3DMap.html


Should I make an issue? It took me a while to figure out that _3d solution.

Cheers,
Raymond
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer