我使用 pip3 install metpy 安装了 Metpy。然而,当我尝试使用露点温度的简单示例时,除了错误之外什么也没有得到。这些错误(我认为)与导入语句有关。我正在使用:
import metpy.calc as mpcalc
from metpy.units import units
mixing = 10 * units('g/kg')
print(mixing)
我收到以下错误:
File "/Users/johnbarrett/dewpoint.py", line 1, in <module>
import metpy.calc as mpcalc
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/__init__.py", line 13, in <module>
from .xarray import * # noqa: F401, F403, E402
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/xarray.py", line 31, in <module>
from .units import (_mutate_arguments, DimensionalityError, is_quantity, UndefinedUnitError,
units)
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/units.py", line 26, in <module>
import pint
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/__init__.py", line 18, in <module>
from .delegates.formatter._format_helpers import formatter
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/__init__.py", line 12, in <module>
from . import txt_defparser
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/__init__.py", line 12, in <module>
from .defparser import DefParser
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/defparser.py", line 10, in <module>
from . import block, common, context, defaults, group, plain, system
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/common.py", line 23, in <module>
@dataclass(frozen=True)
~~~~~~~~~^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/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 "/Library/Frameworks/Python.framework/Versions/3.13/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
➜ ~ python3 dewpoint.py
Traceback (most recent call last):
File "/Users/johnbarrett/dewpoint.py", line 1, in <module>
import metpy.calc as mpcalc
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/__init__.py", line 13, in <module>
from .xarray import * # noqa: F401, F403, E402
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/xarray.py", line 31, in <module>
from .units import (_mutate_arguments, DimensionalityError, is_quantity, UndefinedUnitError,
units)
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/units.py", line 26, in <module>
import pint
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/__init__.py", line 18, in <module>
from .delegates.formatter._format_helpers import formatter
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/__init__.py", line 12, in <module>
from . import txt_defparser
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/__init__.py", line 12, in <module>
from .defparser import DefParser
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/defparser.py", line 10, in <module>
from . import block, common, context, defaults, group, plain, system
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/common.py", line 23, in <module>
@dataclass(frozen=True)
~~~~~~~~~^^^^^^^^^^^^^
➜ ~ python3 dewpoint.py
Traceback (most recent call last):
File "/Users/johnbarrett/dewpoint.py", line 1, in <module>
import metpy.calc as mpcalc
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/__init__.py", line 13, in <module>
from .xarray import * # noqa: F401, F403, E402
^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/xarray.py", line 31, in <module>
from .units import (_mutate_arguments, DimensionalityError, is_quantity, UndefinedUnitError,
units)
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/metpy/units.py", line 26, in <module>
import pint
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/__init__.py", line 18, in <module>
from .delegates.formatter._format_helpers import formatter
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/__init__.py", line 12, in <module>
from . import txt_defparser
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/__init__.py", line 12, in <module>
from .defparser import DefParser
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/defparser.py", line 10, in <module>
from . import block, common, context, defaults, group, plain, system
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pint/delegates/txt_defparser/common.py", line 23, in <module>
@dataclass(frozen=True)
~~~~~~~~~^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/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 "/Library/Frameworks/Python.framework/Versions/3.13/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
任何帮助将不胜感激, 非常感谢约翰