I'm building an internal lib for my company that rely on service accounts to reach Google Earth Engine API. The previous developer went to excessive length to make sure that the ee.Initialize() method was never called twice for the same account in the same session.

A simple example would be:

# connect to the service account
credential_file_path = credential_folder_path / "ee-private-key.json"
credentials = ee.ServiceAccountCredentials("", str(credential_file_path))
ee.Initialize(credentials=credentials, http_transport=httplib2.Http())

# do ee stuff 
number = ee.Number(1)

# connect again 
ee.Initialize(credentials=credentials, http_transport=httplib2.Http())

# do other ee stuff 

I tried locally and it ran smoothly so is it a problem?

1 Answer 1


It's no big deal if you call it twice. Most of the library notices that it's already been initialized once and skips doing unnecessary work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.