Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metpy 1.6.2 seems incompatible with xarray 2024.9.0 #3651

Closed
sgofferj opened this issue Oct 9, 2024 · 5 comments
Closed

Metpy 1.6.2 seems incompatible with xarray 2024.9.0 #3651

sgofferj opened this issue Oct 9, 2024 · 5 comments
Labels
Status: Upstream Needs work done in upstream project

Comments

@sgofferj
Copy link

sgofferj commented Oct 9, 2024

What went wrong?

When using metpy 1.6.3 with xarray 2024.9.0, importing metpy fails

I'm building a docker container with this requirements.txt:

numpy
matplotlib
pandas
xarray
metpy
cartopy
requests
cfgrib
eccodes

Until a couple of days ago, my app would work fine. It still builds fine but when I run it it fails as described below. On my desktop with xarray 2024.6.0 and metpy 1.6.2, the app runs fine.

Packages in docker container:

Package            Version
------------------ -----------
appdirs            1.4.4
attrs              24.2.0
Cartopy            0.24.1
certifi            2024.8.30
cffi               1.17.1
cfgrib             0.9.14.1
charset-normalizer 3.4.0
click              8.1.7
contourpy          1.3.0
cycler             0.12.1
eccodes            2.38.1
findlibs           0.0.5
flexcache          0.3
flexparser         0.3.1
fonttools          4.54.1
idna               3.10
kiwisolver         1.4.7
matplotlib         3.9.2
MetPy              1.6.3
numpy              2.1.2
packaging          24.1
pandas             2.2.3
pillow             10.4.0
Pint               0.24.3
pip                24.2
platformdirs       4.3.6
pooch              1.8.2
pycparser          2.22
pyparsing          3.1.4
pyproj             3.7.0
pyshp              2.3.1
python-dateutil    2.9.0.post0
pytz               2024.2
requests           2.32.3
scipy              1.14.1
shapely            2.0.6
six                1.16.0
traitlets          5.14.3
typing_extensions  4.12.2
tzdata             2024.2
urllib3            2.2.3
xarray             2024.9.0

Operating System

Linux

Version

1.6.3

Python Version

3.13.0

Code to Reproduce

import metpy.calc as mpcalc
from metpy.units import units

Errors, Traceback, and Logs

Traceback (most recent call last):

File "/app/main.py", line 2, in

import functions as func

File "/app/functions.py", line 5, in

import metpy.calc as mpcalc

File "/venv/lib/python3.13/site-packages/metpy/init.py", line 13, in

from .xarray import *  # noqa: F401, F403, E402

^^^^^^^^^^^^^^^^^^^^^

File "/venv/lib/python3.13/site-packages/metpy/xarray.py", line 31, in

from .units import (_mutate_arguments, DimensionalityError, is_quantity, UndefinedUnitError,

                    units)

File "/venv/lib/python3.13/site-packages/metpy/units.py", line 26, in

import pint

File "/venv/lib/python3.13/site-packages/pint/init.py", line 18, in

from .delegates.formatter._format_helpers import formatter

File "/venv/lib/python3.13/site-packages/pint/delegates/init.py", line 12, in

from . import txt_defparser

File "/venv/lib/python3.13/site-packages/pint/delegates/txt_defparser/init.py", line 12, in

from .defparser import DefParser

File "/venv/lib/python3.13/site-packages/pint/delegates/txt_defparser/defparser.py", line 10, in

from . import block, common, context, defaults, group, plain, system

File "/venv/lib/python3.13/site-packages/pint/delegates/txt_defparser/common.py", line 23, in

@dataclass(frozen=True)

 ~~~~~~~~~^^^^^^^^^^^^^

File "/usr/local/lib/python3.13/dataclasses.py", line 1295, in wrap

return _process_class(cls, init, repr, eq, order, unsafe_hash,

                      frozen, match_args, kw_only, slots,

                      weakref_slot)

File "/usr/local/lib/python3.13/dataclasses.py", line 1043, in _process_class

raise TypeError('cannot inherit frozen dataclass from a '

                'non-frozen one')

TypeError: cannot inherit frozen dataclass from a non-frozen one

@sgofferj sgofferj added the Type: Bug Something is not working like it should label Oct 9, 2024
@sgofferj
Copy link
Author

sgofferj commented Oct 9, 2024

Actually, it seems, the problem is Python 3.13. After some more debugging, my application seems to run fine with latest metpy and latest xarray under Python 3.12.7

@DWesl
Copy link
Contributor

DWesl commented Oct 9, 2024

Related question: what happens if you run import pint in the python environment where your app fails, without attempting to import MetPy or XArray? That appears three lines down from the MetPy import.

EDIT: reasoning: it looks like the problem is a conflict between pint and Python 3.13

@sgofferj
Copy link
Author

I'll build a new bad one and test.

@dopplershift
Copy link
Member

Yes, this is a known problem with pint on Python 3.13. I'm going to try to dig in further when I have the cycles. The only work-around right now is to use Python < 3.13.

@dopplershift dopplershift added Status: Upstream Needs work done in upstream project and removed Type: Bug Something is not working like it should labels Oct 14, 2024
ana-v-espinoza added a commit to ana-v-espinoza/science-gateway that referenced this issue Oct 25, 2024
ana-v-espinoza added a commit to Unidata/science-gateway that referenced this issue Oct 25, 2024
@dopplershift
Copy link
Member

Pint has released 0.24.4 (needing flexparser 0.4) that fixes this and allows Python 3.13 to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Upstream Needs work done in upstream project
Projects
None yet
Development

No branches or pull requests

3 participants