为什么在导入 MetPy 子模块时会出现此错误?
Why do I get this error when importing MetPy submodules?
我刚刚第一次使用
安装了 MetPy
conda install -c conda-forge metpy
低于 Mac OS X 10.14(莫哈韦沙漠)。我好像得到了 metpy-0.11.1
接下来的行会生成在底部复制的错误诊断。
from metpy.plots import StationPlot
如果我改为尝试
,我会得到完全相同的错误 (TypeError: find_intersections takes 5 parameters, but 3 units were passed
)
import metpy.calc as mpcalc
如果我使用
导入整个模块,我不会收到错误消息
import metpy
我以前从未遇到过任何已建立的 Python 包的导入错误,所以任何调试我的设置的帮助都将不胜感激。
TypeError Traceback (most recent call
last) in
----> 1 from metpy.plots import StationPlot
2
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/plots/init.py
in
11 from .ctables import * # noqa: F403
12 from .declarative import * # noqa: F403
---> 13 from .skewt import * # noqa: F403
14 from .station_plot import * # noqa: F403
15 from .wx_symbols import * # noqa: F403
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/plots/skewt.py
in
27
28 from ._util import colored_line
---> 29 from ..calc import dewpoint, dry_lapse, moist_lapse, vapor_pressure
30 from ..calc.tools import _delete_masked_points
31 from ..deprecation import metpyDeprecation
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/calc/init.py
in
5
6 from .basic import * # noqa: F403
----> 7 from .cross_sections import * # noqa: F403
8 from .indices import * # noqa: F403
9 from .kinematics import * # noqa: F403
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/calc/cross_sections.py
in
12
13 from .basic import coriolis_parameter
---> 14 from .tools import first_derivative
15 from ..package_tools import Exporter
16 from ..xarray import check_axis, check_matching_coordinates
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/calc/tools.py
in
104 @preprocess_xarray
105 @units.wraps(('=A', '=B'), ('=A', '=B', '=B'))
--> 106 def find_intersections(x, a, b, direction='all', log_x=False):
107 """Calculate the best estimate of intersection.
108
~/miniconda3/envs/scipy/lib/python3.6/site-packages/pint/registry_helpers.py
in decorator(func)
246 raise TypeError(
247 "%s takes %i parameters, but %i units were passed"
--> 248 % (func.name, count_params, len(args))
249 )
250
TypeError: find_intersections takes 5 parameters, but 3 units were
passed
我的猜测是您为旧版本的 MetPy 安装了太新的 Pint 版本 (>= 0.10)。我至少会用 conda install -c conda-forge metpy=0.12.2
更新 metpy。您可以尝试使用 conda update -c conda-forge --all
.
更新所有内容
我刚刚第一次使用
安装了 MetPyconda install -c conda-forge metpy
低于 Mac OS X 10.14(莫哈韦沙漠)。我好像得到了 metpy-0.11.1
接下来的行会生成在底部复制的错误诊断。
from metpy.plots import StationPlot
如果我改为尝试
,我会得到完全相同的错误 (TypeError: find_intersections takes 5 parameters, but 3 units were passed
)
import metpy.calc as mpcalc
如果我使用
导入整个模块,我不会收到错误消息import metpy
我以前从未遇到过任何已建立的 Python 包的导入错误,所以任何调试我的设置的帮助都将不胜感激。
TypeError Traceback (most recent call last) in ----> 1 from metpy.plots import StationPlot 2
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/plots/init.py in 11 from .ctables import * # noqa: F403 12 from .declarative import * # noqa: F403 ---> 13 from .skewt import * # noqa: F403 14 from .station_plot import * # noqa: F403 15 from .wx_symbols import * # noqa: F403
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/plots/skewt.py in 27 28 from ._util import colored_line ---> 29 from ..calc import dewpoint, dry_lapse, moist_lapse, vapor_pressure 30 from ..calc.tools import _delete_masked_points 31 from ..deprecation import metpyDeprecation
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/calc/init.py in 5 6 from .basic import * # noqa: F403 ----> 7 from .cross_sections import * # noqa: F403 8 from .indices import * # noqa: F403 9 from .kinematics import * # noqa: F403
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/calc/cross_sections.py in 12 13 from .basic import coriolis_parameter ---> 14 from .tools import first_derivative 15 from ..package_tools import Exporter 16 from ..xarray import check_axis, check_matching_coordinates
~/miniconda3/envs/scipy/lib/python3.6/site-packages/metpy/calc/tools.py in 104 @preprocess_xarray 105 @units.wraps(('=A', '=B'), ('=A', '=B', '=B')) --> 106 def find_intersections(x, a, b, direction='all', log_x=False): 107 """Calculate the best estimate of intersection. 108
~/miniconda3/envs/scipy/lib/python3.6/site-packages/pint/registry_helpers.py in decorator(func) 246 raise TypeError( 247 "%s takes %i parameters, but %i units were passed" --> 248 % (func.name, count_params, len(args)) 249 ) 250
TypeError: find_intersections takes 5 parameters, but 3 units were passed
我的猜测是您为旧版本的 MetPy 安装了太新的 Pint 版本 (>= 0.10)。我至少会用 conda install -c conda-forge metpy=0.12.2
更新 metpy。您可以尝试使用 conda update -c conda-forge --all
.