arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

Getting error NameError: name 'Image' is not defined while running cells in Google Colab

Open Daremitsu1 opened this issue 2 years ago • 10 comments

Describe the bug Hello, I have followed the steps to run arcgis in Google Colab. However while trying to import GIS from arcgis I am facing the error NameError: name 'Image' is not defined

To Reproduce Steps to reproduce the behavior:

  1. Ran the following code cell:
%%bash
MINICONDA_INSTALLER_SCRIPT=Miniconda3-4.5.4-Linux-x86_64.sh
MINICONDA_PREFIX=/usr/local
wget https://repo.continuum.io/miniconda/$MINICONDA_INSTALLER_SCRIPT
chmod +x $MINICONDA_INSTALLER_SCRIPT
./$MINICONDA_INSTALLER_SCRIPT -b -f -p $MINICONDA_PREFIX

conda install -c esri -c fastai -c pytorch -c anaconda arcgis=1.8.4 ujson scikit-image=0.15.0 pillow=7.1.2 libtiff=4.1.0 fastai=1.0.60 pytorch=1.4.0 torchvision=0.5.0 python=3.7.9 --yes --no-pin
  1. After which I ran the following:
import sys
sys.path
 
 
import sys
_ = (sys.path
 .append("/usr/local/lib/python3.7/site-packages"))
  1. Finally, when I tried to ran the following cell resulting in the error:
import os
import zipfile
from pathlib import Path
from arcgis.gis import GIS
from arcgis.learn import prepare_textdata
from arcgis.learn.text import SequenceToSequence
  1. The Error:
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
[<ipython-input-7-d47f19c7f286>](https://localhost:8080/#) in <module>()
      3 from pathlib import Path
      4 from arcgis.gis import GIS
----> 5 from arcgis.learn import prepare_textdata
      6 from arcgis.learn.text import SequenceToSequence

5 frames
[/usr/local/lib/python3.7/site-packages/arcgis/learn/_utils/common.py](https://localhost:8080/#) in <module>()
     95     raise Exception(message)
     96 
---> 97 class ArcGISMSImage(Image):
     98 
     99     def show(self, ax=None, rgb_bands=None, show_axis=False, title=None):

NameError: name 'Image' is not defined

Screenshots Screenshots for the problem: image

Expected behavior The cells would have ran with the dependencies getting imported.

Platform (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Python API Version [e.g. 1.6.2]: Getting error NameError: name 'arcgis' is not defined

Daremitsu1 avatar Aug 04 '22 07:08 Daremitsu1

Any update on this?

Daremitsu1 avatar Sep 02 '22 10:09 Daremitsu1

Hi there @Daremitsu1 ,

Sorry for the delay on this! We actually have a Google Colab installation section coming in our next update to the API guide. Here's a screenshot of our current recommended steps. Feel free to provide an update on how this works for you. Screen Shot 2022-09-16 at 2 45 26 PM

nparavicini7 avatar Sep 16 '22 21:09 nparavicini7

@Daremitsu1 Did this solution help?

nanaeaubry avatar Oct 18 '22 19:10 nanaeaubry

No. Because it did not solve the problem of installing deep learning libraries. That problem is still persisting. Would be grateful if the Esri team provides a proper documentation on installing them in Colab.

Daremitsu1 avatar Oct 25 '22 06:10 Daremitsu1

@priyankatuteja Can you assist with this please?

nanaeaubry avatar Oct 25 '22 14:10 nanaeaubry

Hi, it could be awesome to have a step-by-step guide, unfortunately, I have the same problems. I would like to run deep learning libraries and arcgis notebook examples. Waiting for the Google Colab installation section!!! @nparavicini7

paolodep36 avatar Nov 03 '22 08:11 paolodep36

@paolodep36 can you provide an example of code that's failing?

nparavicini7 avatar Nov 03 '22 21:11 nparavicini7

@Daremitsu1 are the import statements that were failing you still failing after following the instructions in screenshot from my prior comment? After creating a new notebook, running !sudo apt-get install libkrb5-dev and !pip install arcgis (and possibly restarting the runtime), I'm able to import all of the modules from your screenshot. Google colab environments come pre-loaded with the majority, if not all, of the necessary packages to work with arcgis learn.

And if those same imports are still failing, are you still getting the same error message?

nparavicini7 avatar Nov 03 '22 22:11 nparavicini7

@nparavicini7 Hi, I successfully managed to install api version 1.8.4 running !sudo apt-get install libkrb5-dev and !pip install arcgis==1.8.4 torch==1.4.0 fastai==1.0.60 torchvision=0.5.0

in order to run the deep learning modules, you have to install the right torch library, torchvision, and fastai.

I succeeded for api version 1.8.4 but not yet for version 2.0.1 which requires different versions of pytorch, fastai and torchvision. Could you tell me what versions of pytorch and fastai I can install via pip install? If I run only pip install arcgis deep learning modules will not work because pip installs the last version of torch and fastai that are incompatible with arcgisapi. Obviously I need this because I want to run sample notebooks with GPU. I saw that there is a conda package: arcgis_learn and another one for windows deep learning essentials. Are there any similar packages to run with pip?

paolodep36 avatar Nov 04 '22 07:11 paolodep36

@paolodep36 no there is no pip equivalent. The deep learning conda install is a meta package, you can comb through it and install all the requirements using pip.

achapkowski avatar Jun 22 '23 11:06 achapkowski