3

I´m working on a main script with additional code based in a lib folder like this:

main.py
\mylib
  util.py (contains the class Utility)
  node.py
in main.py I´ve imported mylib like this:

from mylib.util import Utility
x = Utility()

It seems like QGIS python console caches the mylib on startup - changes made to the Utility class made after startup is ignored.

Is there a way to reload mylib without restarting QGIS?

5
  • Perhaps this post might help: Re-import custom functions without restarting QGIS
    – Joseph
    Commented Mar 31, 2017 at 9:06
  • I´ve tried the reload approach, but I get a console error like: reload() argument must be module. Any idea what I´m doing wrong? Commented Mar 31, 2017 at 11:34
  • Sorry, I'm not sure how to reload lib folders as I normally just reload the main.py file :)
    – Joseph
    Commented Mar 31, 2017 at 11:43
  • 1
    Hi again Joseph. I´ve figured out, that reload(mylib) doesn´t throw an error - but on the other hand util.py isn´t reloaded. Thanks for your advice anyway. I´ll try searching some more Commented Mar 31, 2017 at 11:59
  • 1
    Please note that there is a {} button that enables you to format any highlighted code nicely.
    – PolyGeo
    Commented Mar 31, 2017 at 12:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.