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?

axel_ande
2,13415 silver badges28 bronze badges
asked Mar 31, 2017 at 9:00
5
  • Perhaps this post might help: Re-import custom functions without restarting QGIS 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 :) 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. Commented Mar 31, 2017 at 12:18

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.