我无法再使用 Python 在 Google
colab
上初始化我自己的地球引擎项目。
我尝试使用 Colab 上的
ee.Initialize()
方法进行初始化,用于提供一个链接,该链接将为我的项目生成令牌,但我收到此错误:
WARNING:googleapiclient.http:Encountered 403 Forbidden with reason "PERMISSION_DENIED"
---------------------------------------------------------------------------
HttpError Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/ee/data.py in _execute_cloud_call(call, num_retries)
382 try:
--> 383 return call.execute(num_retries=num_retries)
384 except googleapiclient.errors.HttpError as e:
7 frames
HttpError: <HttpError 403 when requesting https://earthengine.googleapis.com/v1/projects/earthengine-legacy/algorithms?prettyPrint=false&alt=json returned "Google Earth Engine API has not been used in project 522309567947 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=522309567947 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.". Details: "[{'@type': 'type.googleapis.com/google.rpc.Help', 'links': [{'description': 'Google developers console API activation', 'url': 'https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=522309567947'}]}, {'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'SERVICE_DISABLED', 'domain': 'googleapis.com', 'metadata': {'service': 'earthengine.googleapis.com', 'consumer': 'projects/522309567947'}}]">
During handling of the above exception, another exception occurred:
EEException Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/ee/data.py in _execute_cloud_call(call, num_retries)
383 return call.execute(num_retries=num_retries)
384 except googleapiclient.errors.HttpError as e:
--> 385 raise _translate_cloud_exception(e) # pylint: disable=raise-missing-from
386
387
EEException: Google Earth Engine API has not been used in project 522309567947 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/earthengine.googleapis.com/overview?project=522309567947 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry
.
还提供了解决方案这里
它涉及进入您的 Google Cloud 帐户并显式激活 GEE api,然后创建一个新项目,您最终在调用 ee.Initialize() 时指定该项目。这样做的好处是,当您从 Colab 调用 GEE 时,您不再需要通过一系列复杂的点击和链接来获取令牌,它只是运行并激活。一开始会令人沮丧,但从长远来看,这可以节省时间。