Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing earth engine on Ubuntu

I want to install Earth Engine API on Python on Ubuntu 18.04. I have both Python 2.7 and Python 3.6 installed on my system, and I install Earth Engine using both pip and pip3 as instructed (installing google-api-python-client, oauth2client, and earthengine-api) without any problem. But I get errors on both 2.7 and 3.6:

On Python 2.7, "import ee" works but "ee.Initialize()" returns this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'Initialize'

On Python 3.6, "import ee" doesn't work and return this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sshahhey/.local/lib/python3.6/site-packages/ee/__init__.py", line 1, in <module>
    from .main import main
  File "/home/sshahhey/.local/lib/python3.6/site-packages/ee/main.py", line 10, in <module>
    import StringIO
ModuleNotFoundError: No module named 'StringIO'

Any help? I am particularly interested in solving the problem for Python 3.

like image 758
Shahriar49 Avatar asked Apr 19 '26 13:04

Shahriar49


1 Answers

Following up on Kevin's answer:

I had this same issue, but the state of my /usr/local/lib/python2.7/site-packages/ee looked the same as that of my coworker, whose Earth Engine API was working fine. The issue is that there are 2 pip packages which write to the same directory:

  • earthengine-api:
    • this is the package you want
    • writes the Earth Engine library to site-packages/ee
  • ee:
    • Unrelated to EE, just a wrapper for dd
    • writes a main.py and __init__.py to site-packages/ee

The only difference between our two setups was the order in which we installed those packages. For me, installing ee second overwrote the __init__.py file, which prevented the ee module from importing the library contents. The fix was to completely clear out the directory and related dist-info dir, and start over:

  1. rm -rf /usr/local/lib/python2.7/site-packages/ee
  2. rm -rf /usr/local/lib/python2.7/site-packages/earthengine_api-0.1.182.dist-info
  3. sudo pip install earthengine_api
like image 89
S. Bloch Avatar answered Apr 29 '26 05:04

S. Bloch