Hi Eric, On Wed, 02. Oct 2019 at 11:32:36 +0200, Eric Lemoine wrote: > Hi QGIS devs! > > I need to use a PyQGIS startup script (set via the PYQGIS_STARTUP > envvar). And I want to do "import qgis" from that startup script! > > It works on Linux, because PyQGIS is installed in the system-wide > Python environment. So no problem here. > > But it doesn't work with OSGeo4W. OSGeo4W installs PyQGIS in > C:/OSGeo4W64/apps/qgis/python, and that path isn't in sys.path when my > startup script is executed. > > The C:\OSGeo4W64\bin\qgis-bin.env file indeed does not set PYTHONPATH. > Likewise, the C:\OSGeo4W64\bin\py3_env.bat file, which > C:\OSGeo4W64\bin\qgis.bat includes, has "SET PYTHONPATH=" (PYTHONPATH > set to nothing). > > What do you think? Shouldn't OSGeo4W set PYTHONPATH to > "%OSGEO4W_ROOT%\apps\qgis\python;%PYTHONPATH%" in py3_env.bat and > qgis-bin.env for startup scripts to be able to import and use the qgis > module?
No. py3_env.bat belongs to osgeo4w's python and just switches to python3. It shouldn't know about qgis. It's used with everything that use python3 (eg. several qgis versions). Not sure why PYQGIS_STARTUP is used that early. The python path is added shortly after it was referenced: https://github.com/qgis/QGIS/blob/master/src/python/qgspythonutilsimpl.cpp#L98 So other platforms should have the same issue. Jürgen -- Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-31 Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50 Software Engineer D-26506 Norden https://www.norbit.de QGIS release manager (PSC) Germany IRC: jef on FreeNode
signature.asc
Description: PGP signature
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH Rheinstrasse 13, 26506 Norden GF: Juergen Fischer, Nils Kutscher HR: Amtsgericht Aurich HRB 100827 Datenschutzerklaerung: https://www.norbit.de/83/
_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
