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

AttributeError: module 'numpy' has no attribute 'alen' #3423

Open
chojeonga opened this issue Mar 6, 2024 · 6 comments
Open

AttributeError: module 'numpy' has no attribute 'alen' #3423

chojeonga opened this issue Mar 6, 2024 · 6 comments
Labels
Type: Bug Something is not working like it should

Comments

@chojeonga
Copy link

What went wrong?

I got AttributeError

from metpy.interpolate import (interpolate_to_grid, remove_nan_observations, remove_repeat_coordinates)

AttributeError: module 'numpy' has no attribute 'alen'

Operating System

MacOS

Version

metpy1.6

Python Version

python 3.10.9

Code to Reproduce

from metpy.interpolate import (interpolate_to_grid, remove_nan_observations, remove_repeat_coordinates)

Errors, Traceback, and Logs

No response

@chojeonga chojeonga added the Type: Bug Something is not working like it should label Mar 6, 2024
@akrherz
Copy link
Contributor

akrherz commented Mar 6, 2024

How did you install MetPy? Can you please provide the full python traceback for the AttributeError?

@chojeonga
Copy link
Author

chojeonga commented Mar 6, 2024

conda install -c conda-forge metpy
Traceback (most recent call last):
  File "/Users/eprl/workplace/Prediction/code/plot/4_interpolation.py", line 10, in <module>
    from metpy.interpolate import (interpolate_to_grid, remove_nan_observations,
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/metpy/__init__.py", line 35, in <module>
    from .xarray import *  # noqa: F401, F403
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/metpy/xarray.py", line 28, in <module>
    from .units import DimensionalityError, UndefinedUnitError, units
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/metpy/units.py", line 22, in <module>
    import pint
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/pint/__init__.py", line 28, in <module>
    from .measurement import Measurement
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/pint/measurement.py", line 12, in <module>
    from .quantity import Quantity
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/pint/quantity.py", line 47, in <module>
    from .numpy_func import (
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/pint/numpy_func.py", line 860, in <module>
    implement_func("function", func_str, input_units=None, output_unit=None)
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/pint/numpy_func.py", line 263, in implement_func
    func = getattr(np, func_str_split[0])
  File "/Users/eprl/anaconda3/lib/python3.10/site-packages/numpy/__init__.py", line 311, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'alen'

@akrherz
Copy link
Contributor

akrherz commented Mar 6, 2024

sounds like an incompatable version of numpy, which version do you have installed? see hgrecco/pint#1532

@dopplershift
Copy link
Member

Yes, the output of conda list numpy and conda list pint would be helpful.

@chojeonga
Copy link
Author

chojeonga commented Mar 7, 2024

Which one should I delete?

Name Version Build Channel

numpy 1.23.4 py310hb93e574_0
numpy-base 1.23.4 py310haf87e8b_0
numpydoc 1.5.0 py310hca03da5_0

Name Version Build Channel

pint 0.11 py_1 conda-forge/label/cf202003

@dopplershift
Copy link
Member

pint 0.11 is way too old, and I'm not even sure how that's installed given that on conda-forge, MetPy 1.6 lists pint >= 0.17 as one of its requirements.

Regardless, I think your solution should be: conda update pint, which should install pint 0.23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something is not working like it should
Projects
None yet
Development

No branches or pull requests

3 participants