AttributeError when running google colab notebooks

Hello! I wanted to use again the google colab for "notebook 1.2 open data access with GWpy and to my surprise I got the following error almost at the very beginning of the notebook:

AttributeError Traceback (most recent call last)

in <cell line: 1>()
----> 1 plot = ldata.plot()

5 frames

/usr/local/lib/python3.10/dist-packages/gwpy/plot/ in to_string(cls, unit)
37 if unit.physical_type not in {None, ‘unknown’, ‘dimensionless’}:
38 ptype = str(unit.physical_type).split(‘/’, 1)[0].title()
—> 39 return f"{cls._latex_escape(ptype)} {u}"
40 return u

AttributeError: type object ‘LatexInlineDimensional’ has no attribute ‘_latex_escape’

I was wondering why it is not working now? I tried with other notebooks and I get the same error, for example in notebook 1.3 when you want to plot the specgram. It seems the problem appears with the plot instruction: plot = ldata.plot() and plot = specgram.plot().

Thank you in advance!

Hello Lucy,

It seems there was a problem with how gwpy modified the astropy package for the physical units.

I have checked with the new stable gwpy 3.0.5 package, and it works. I would suggest you to install a more recent version of gwpy, which is gwpy 3.0.5 (If you are using Google Colab, edit the first cell where it installs gwpy 3.0.4 to 3.0.5).

Try this and check, do let me know if it doesn’t get resolved.


Hi @Anirudh_Nemmani !
Yes, that solved the problem! Thank you so much!!! :hugs: