Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.91k stars 1.11k forks source link

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

Open Daremitsu1 opened 2 years ago

Daremitsu1 commented 2 years ago

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

2. After which I ran the following:

import sys sys.path

import sys _ = (sys.path .append("/usr/local/lib/python3.7/site-packages"))


3. Finally, when I tried to ran the following cell resulting in the error:

```python
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 in () 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](https://user-images.githubusercontent.com/54842807/182793875-048645ad-8596-49cd-84e2-c8505befb5d4.png)

**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 commented 2 years ago

Any update on this?

nparavicini7 commented 2 years ago

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
nanaeaubry commented 2 years ago

@Daremitsu1 Did this solution help?

Daremitsu1 commented 2 years ago

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.

nanaeaubry commented 2 years ago

@priyankatuteja Can you assist with this please?

paolodep36 commented 2 years ago

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

nparavicini7 commented 2 years ago

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

nparavicini7 commented 2 years ago

@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?

paolodep36 commented 2 years ago

@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?

achapkowski commented 1 year ago

@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.