I have been developing a custom made plugin over the last month and recently I have noticed that when I reload the plugin with plugin reloader the plugin work just fine for the first use. In the plugin I load layers into python where I safe them into a pandas DF which I use to create a bar graph with matplotlib. Now the error that occurse is when I use the plugin (without reloading it) for the second time, now the plugin gives me an error that the DF where I normally safe my data is empty. Meaning that the plugin didn't load any of the data from the selected layers into the DF.

My best quess is that it has to do something with correctly loading and unloading the plugin after use but I can't figure out where I should fix this. Is there anybody that can help me with this or knows of a different reason that this could happen?

  • Oof, I have vague memories of something like that happening to me back when I started out. Been a while since then, unfortunately. If I remember correctly, it might have been a hidden permission error - That the file I was modifying with my algorithm was still locked because QGIS (the previous run of the algorithm) still had a hold on the file. Could something like that be happening here?
    – Noxy
    Commented Jul 31, 2023 at 12:52
  • @Noxy thanks a lot for your awnser! I do believe something like this could happen. In the code I write to a csv from which I later read the data again, I create TEMP layers since I use other plugins within my plugin and open a plot in matplot that I write to an png. I assume it then must be a problem with one of these, would you also have any suggestions on how I could avoid this error? I wouldn't know how to let go of the file so that the permission error doesn't occur. Thanks in advance for thinking along :)
    – JasperB
    Commented Aug 8, 2023 at 8:21
  • In my case, this is pretty much how I solved it: How to release PyQGIS file locks. Note that my algorithm uses pseudo-temporary files (meaning regular files I "manually" delete) because I never did manage to get any of the integrated temporary file options to work. Shouldn't make a difference, but well, FYI
    – Noxy
    Commented Aug 8, 2023 at 14:36


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.