[QGIS-Developer] PyQGIS unavailable at QGIS startup time on OSGeo4W
Eric Lemoine
eric.lemoine at oslandia.com
Wed Oct 2 02:32:36 PDT 2019
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?
Thanks!
--
Éric Lemoine
Oslandia
More information about the QGIS-Developer
mailing list