3

I would like to use a startup.py which is part of a rollout and not located inside the users config-folder (like ~/.qgis2).

Plugins located in the apps folder (e.g. C:\OSGeo4W64\apps\qgis-ltr\python) are working but if I try to use a startup.py in this folder it isn't executed.

Is there something I can do to get this startup.py executed or is this a bug?

5
  • check this gis.stackexchange.com/questions/194055/…
    – Fran Raga
    Sep 24, 2018 at 6:26
  • @FranciscoRaga: thanks for the link but this answers do not help to answer my question. The startup.py itself is correct and working if I put it in the users folders. My question is just why it is not executed when put into the python folder of the QGIS install.(If this path is C:\Program Files\QGIS\python, C:\OSGeo4W64\apps\qgis-ltr\python or something else depends on the installer and the choice of the user during installation Sep 24, 2018 at 6:48
  • ah okey,then check this,using startup.py outside user folder ,Is the same question asked by you?, gis.stackexchange.com/questions/283317/…
    – Fran Raga
    Sep 24, 2018 at 7:05
  • @FranciscoRaga: the linked question answeres the question how to start python code during startup with the --code option but not why a startup.py is not executed when put in the python folder of the QGIS programm folder. Sep 24, 2018 at 8:17
  • 1
    Qgis auto execute startup.py in user folder not in other folder,is programmed like this,if you want that execute need add this file to sys path gis.stackexchange.com/a/263448/49538
    – Fran Raga
    Sep 24, 2018 at 8:38

1 Answer 1

1

QGIS does only execute core python plugins from this folder and these plugins can't be extended. Try to store a plugin there, it will not be touched by qgis.

Even if this would be possible, a simple startup.py does not fulfill the requirements of a plugin, which has the structure of a python package, which means it consists of a folder whith file init.py, a function named classFactory and more, described in the pyqgis developer cookbook

At least there is a chance to have a "system wide startup.py" by opening a QGIS-Ticket as a feature request.

3
  • QGIS executes all python plugins from this folder, not only the core plugins: i.stack.imgur.com/BeX1r.png . I have tested this before with several plugins. That's why I wrote: "Plugins located in the apps folder (e.g. C:\OSGeo4W64\apps\qgis-ltr\python) are working". Sep 26, 2018 at 6:54
  • I also tried this, but i must admit, it was not a full functioning plugin. My idea was to use a plugin as a startup script. I tried to use initGui() as an entry point, because that's where the button or menu entries are added to qgis. Unfortunately even __init__.py wasn't executed. This and the explicit mention that the core plugins are seleted by the developer team leads to my conclusion. Therefor using a plugin as a startup may be investigated further. Sep 26, 2018 at 7:53
  • I also considered using a plugin as a startup but realised that it is not an option as it can be deactivated. I want to check if a ntv2-grid is correctly integrated in QGIS during startup. If the plugin would be deactivated this could lead to inaccurate data, so a solution that could be deactivated by the user is a showstopper Sep 26, 2018 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.