Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 686
Drosera_capensis Avatar asked Sep 11 '25 19:09

Drosera_capensis


2 Answers

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.

like image 59
M.Ahmadkhani Avatar answered Sep 14 '25 10:09

M.Ahmadkhani


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

like image 27
Drosera_capensis Avatar answered Sep 14 '25 11:09

Drosera_capensis