CDAT / cdat

Community Data Analysis Tools
Other
175 stars 68 forks source link

cannot import name 'rank' from 'numpy.ma' #2252

Closed Xunius closed 4 years ago

Xunius commented 4 years ago

Hi all

I'm installing the cdat-lite using the following:

conda create -n new python=3.7
conda activate new
conda install cdms2 cdutil -c conda-forge

After installation, importing cdms2 or MV2 gives the following error:

>>> import cdms2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/cdms2/__init__.py", line 8, in <module>
    from . import dataset
  File "/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/cdms2/dataset.py", line 24, in <module>
    from .coord import FileAxis2D, DatasetAxis2D
  File "/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/cdms2/coord.py", line 17, in <module>
    from .fvariable import FileVariable
  File "/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/cdms2/fvariable.py", line 7, in <module>
    from .variable import DatasetVariable
  File "/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/cdms2/variable.py", line 17, in <module>
    from .avariable import AbstractVariable
  File "/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/cdms2/avariable.py", line 1933, in <module>
    from . import MV2 as MV  # noqa
  File "/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/cdms2/MV2.py", line 12, in <module>
    from numpy.ma import indices, innerproduct, masked, put, putmask, rank, ravel  # noqa
ImportError: cannot import name 'rank' from 'numpy.ma' (/home/guangzhi/anaconda3/envs/new/lib/python3.7/site-packages/numpy/ma/__init__.py)

My secs:

muryanto1 commented 4 years ago

We have an unofficial release that has some bug fixes (including the one you ran into above) and improvements. Please create your env as follows (for Linux): conda create -n cdat82_mesalib -c cdat/label/v82 -c conda-forge "cdat=8.2" "python=3.7" "numpy=1.17" mesalib="18.3.1" jupyter notebook ipywidgets

Xunius commented 4 years ago

@muryanto1 Thanks, this one worked. I noticed that doing everything in one line also works, like

conda create -n new python=3.7 cdms2 cdutil -c conda-forge

while if I create a new env, activate, then install cdms2 and cdutil, I got the above error message. Why are these 2 different? I always tend to create an empty env and install packages one by one. So is it more preferable to install everything in one go?

muryanto1 commented 4 years ago

@xunius When you install it in one line during conda create, conda tries to find packages that satisfy all dependencies. I did verify that both actually brings in different python and cdms2. you can do 'conda list --explicit' inside both environments to see the difference. In general, I try to install as much as I know in advance during 'conda create'.

Xunius commented 4 years ago

@muryanto1 I see. Thanks.