Problem with StringIO importing ee, although it could be imported alone

1.4k Views Asked by At

I am trying to import the module ee to use the google earth engine according to the documentation on the dedicated website. https://developers.google.com/earth-engine/guides/python_install

I got this error:

import ee

ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_35721/2985164896.py in <module>
----> 1 import ee

~/anaconda3/lib/python3.7/site-packages/ee/__init__.py in <module>
----> 1 from .main import main

~/anaconda3/lib/python3.7/site-packages/ee/main.py in <module>
      8 import stat
      9 import plistlib
---> 10 import StringIO
     11 import platform
     12 import time

ModuleNotFoundError: No module named 'StringIO'

The puzzling thing is that I can import this module without ee flawlessly.

from io import StringIO
import io

Would anyone had the same issue?

2

There are 2 best solutions below

0
Drosera_capensis On

Modifying the original python file at the following location solve the problem:

~/anaconda3/lib/python3.7/site-packages/ee/main.py

Line 10, replace 'import StringIO' by 'from io import StringIO'.

0
M.Ahmadkhani On

It seems like there might have been an incorrect installation command used previously. Please use the following correct command for installation:

pip install earthengine-api

After running the above command you can try importing ee again.