Search code examples
pythonjupytercondamxnetgluon

GluonCV ImportError: cannot import name 'is_np_array'


I'm trying to set up a GluonCV in a jupyter notebook in a virtual environment. For some reason whenever I try to import GluonCV I get this error:

ImportError                               Traceback (most recent call last)
<ipython-input-2-9a2bc396118f> in <module>
----> 1 import gluoncv

~\anaconda3\envs\mxnet\lib\site-packages\gluoncv\__init__.py in <module>
     10 _require_mxnet_version('1.4.0', '2.0.0')
     11 
---> 12 from . import data
     13 from . import model_zoo
     14 from . import nn

~\anaconda3\envs\mxnet\lib\site-packages\gluoncv\data\__init__.py in <module>
     29 from .sampler import SplitSampler, ShuffleSplitSampler
     30 from .otb.tracking import OTBTracking
---> 31 from .kitti.kitti_dataset import KITTIRAWDataset, KITTIOdomDataset
     32 
     33 datasets = {

~\anaconda3\envs\mxnet\lib\site-packages\gluoncv\data\kitti\__init__.py in <module>
      1 # pylint: disable=missing-module-docstring
----> 2 from .kitti_dataset import *
      3 from .kitti_utils import *

~\anaconda3\envs\mxnet\lib\site-packages\gluoncv\data\kitti\kitti_dataset.py in <module>
     19 
     20 from ...utils.filesystem import try_import_skimage
---> 21 from .kitti_utils import generate_depth_map
     22 from .mono_dataset import MonoDataset
     23 

~\anaconda3\envs\mxnet\lib\site-packages\gluoncv\data\kitti\kitti_utils.py in <module>
     10 
     11 import mxnet as mx
---> 12 from mxnet.util import is_np_array
     13 
     14 

ImportError: cannot import name 'is_np_array'

I've tried using the same files that work on Google Collaboratory but I still get that error. I've tried reinstalling gluon and all that stuff in all manners. No idea what's going on. For convenience I really need this to work.


Solution

  • I resolved this error by installing the compatible versions of mxnet and gluoncv.In my case I had installed mxnet with with gluoncv native, that resolved the error.