I was trying to import all modules for ArcGIS to perform a machine learning analysis. However, the code gives me an error at the line from arcgis.learn.


%matplotlib inline

import pandas as pd
from datetime import datetime
from IPython.display import Image
from IPython.display import HTML
import matplotlib.pyplot as plt

from sklearn.preprocessing import MinMaxScaler
from datetime import datetime as dt

import arcgis
from arcgis.gis import GIS
from arcgis.learn import MLModel, prepare_tabulardata
from arcgis.raster import Raster

from fastai.vision import *


NameError Traceback (most recent call last) in 12 import arcgis 13 from arcgis.gis import GIS ---> 14 from arcgis.learn import MLModel, prepare_tabulardata 15 from arcgis.raster import Raster 16

~\anaconda3\envs\prj\lib\site-packages\arcgis\learn_init_.py in 15 16 if not _LAMBDA_TEXT_CLASSIFICATION: ---> 17 from .models import ( 18 SingleShotDetector, 19 UnetClassifier,

~\anaconda3\envs\prj\lib\site-packages\arcgis\learn\models_init_.py in 2 3 if not _LAMBDA_TEXT_CLASSIFICATION: ----> 4 from ._ssd import SingleShotDetector 5 from ._unet import UnetClassifier 6 from ._retinanet import RetinaNet

~\anaconda3\envs\prj\lib\site-packages\arcgis\learn\models_ssd.py in ----> 1 from ._arcgis_model import ArcGISModel, _get_device 2 from pathlib import Path 3 import json 4 from ._codetemplate import code 5 import warnings

~\anaconda3\envs\prj\lib\site-packages\arcgis\learn\models_arcgis_model.py in 33 if not _LAMBDA_TEXT_CLASSIFICATION: 34 from fastai.vision.learner import model_meta, _default_meta ---> 35 from .._utils.common import get_post_processed_model 36 from torchvision import models 37

~\anaconda3\envs\prj\lib\site-packages\arcgis\learn_utils\common.py in 125 126 --> 127 class ArcGISMSImage(Image): 128 def show( 129 self, ax=None, rgb_bands=None, show_axis=False, title=None, return_ax=False

~\anaconda3\envs\prj\lib\site-packages\arcgis\learn_utils\common.py in ArcGISMSImage() 180 181 @classmethod --> 182 def open(cls, path, cast_to=np.float32, div=None, imagery_type=None): 183 path = str(os.path.abspath(path)) 184 if not os.path.exists:

NameError: name 'np' is not defined

What is wrong because I am not using numpy here and it's not needed!

  • Since ArcPy is very dependent on numpy, I imagine that the error is coming from a library dependency. Commented Apr 28, 2022 at 19:51
  • So what do I do to make it work?
    – Saad Ullah
    Commented Apr 29, 2022 at 1:07

1 Answer 1


You may need to check and make sure your conda is up to date. If you go into cmd then type in

where conda

it will let you know if you at least have it installed somewhere.

  • Conda is up to date but same issue
    – Saad Ullah
    Commented Apr 29, 2022 at 0:17
  • Have you run this yet to get esri module installed? conda install arcgis -c esri Commented Apr 29, 2022 at 2:29
  • The first part of the error message is what's making me think it may be a gis module issue. Also, have you tried running these imports in a different IDE? Like one that is connected to ArcPro, such as Spyder or Jupyter Notebooks? Commented Apr 29, 2022 at 2:30
  • Also, you could just try and import numpy, even if it seems you won't be using it. Wouldn't hurt. Commented Apr 29, 2022 at 2:31
  • Yes I am running this in jupyter notebook and have installed everything If I remove the arcgis.learn line then it works
    – Saad Ullah
    Commented Apr 29, 2022 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.