I updated my obspy as suggested in another question.
Now another of my scripts returns an error from matplotlib:
Traceback (most recent call last):
File “./getnPlot.py”, line 838, in
File “/home/seisan/anaconda3/envs/obspy/lib/python3.8/site-packages/matplotlib/figure.py”, line 3065, in set_size_inches
manager.resize(*(size * self.dpi).astype(int))
File “/home/seisan/anaconda3/envs/obspy/lib/python3.8/site-packages/matplotlib/backends/_backend_tk.py”, line 546, in resize
File “/home/seisan/anaconda3/envs/obspy/lib/python3.8/tkinter/init.py”, line 1646, in configure
return self._configure(‘configure’, cnf, kw)
File “/home/seisan/anaconda3/envs/obspy/lib/python3.8/tkinter/init.py”, line 1636, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid command name “.!canvas”
Any suggestions as to why this is happening?
Apologies if these are basic problems, but Python is really doing my head in (I’m a user, not a coder).
I would recommend avoiding to mix very old with very new version of packages that interact with each other whenever possible. The original problem from that other post was mixing a recent Numpy with old obspy. It’s a lot of work for package developers to ensure it works with different versions of their dependencies, so usually tests happen against only fairly recent version of the dependencies (e.g. numpy dropped Python 3.8 support in April 2023). Here it might be a new matplotlib not playing well with old TK (just a guess since we don’t have version number info)?
When you have to update environments doing automated processing tasks, I would recommend (esp. since you are using anaconda anyway) just setting up a new environment with all up to date packages then make sure your workflow works with the new environment and then just switch out what environment you use.
Your problem just might go away updating the whole stack of python, numpy, matplotlib, obspy. (Code might have to get updated in places, depending on what you are doing)
Thanks. My problems come I think when I use other peoples scripts. I don’t fully understand the way of doing things in Python / obspy. I guess I need to spend some time understanding things more.
Thanks. The problem, i think, is that I’m including someone elses scripts. I need to spend more time thinking about how it all works.