0

Fresh install of Mac OSX Catalina (v10.15.7) Running Anaconda 3 and Python 3.8.10

I install the EE Python API client by doing: conda install earthengine-api

Install is successful

I then try to authenticate by doing running sudo earthengine authenticate from the command line. The web window sign-in prompt appears. I sign in to my account, receive a verification code, paste it into terminal, and receive message: 'Successfully saved authorization token.'

Then, I try to initialize like:

python
import ee
ee.Initialize()

and receive the following traceback:

Traceback (most recent call last):
  File "/opt/anaconda3/envs/rsenv/lib/python3.8/site-packages/ee/data.py", line 219, in get_persistent_credentials
    tokens = json.load(open(oauth.get_credentials_path()))
PermissionError: [Errno 13] Permission denied: '/Users/my_username/.config/earthengine/credentials'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/anaconda3/envs/rsenv/lib/python3.8/site-packages/ee/__init__.py", line 115, in Initialize
    credentials = data.get_persistent_credentials()
  File "/opt/anaconda3/envs/rsenv/lib/python3.8/site-packages/ee/data.py", line 229, in get_persistent_credentials
    raise ee_exception.EEException(
ee.ee_exception.EEException: Please authorize access to your Earth Engine account by running

earthengine authenticate

I tried removing the file /Users/my_username/.config/earthengine/credentials and redoing the process without using sudo. In this case, I get the following error:

Traceback (most recent call last):
  File "/opt/anaconda3/envs/my_env/bin/earthengine", line 10, in <module>
    sys.exit(main())
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/cli/eecli.py", line 84, in main
    _run_command()
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/cli/eecli.py", line 63, in _run_command
    dispatcher.run(args, config)
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/cli/commands.py", line 352, in run
    self.command_dict[vars(args)[self.dest]].run(args, config)
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/cli/commands.py", line 385, in run
    ee.Authenticate(**args_auth)
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/__init__.py", line 89, in Authenticate
    oauth.authenticate(authorization_code, quiet, code_verifier)
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/oauth.py", line 235, in authenticate
    _obtain_and_write_token(None, code_verifier)  # Will prompt for auth_code.
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/oauth.py", line 142, in _obtain_and_write_token
    write_token(token)
  File "/opt/anaconda3/envs/my_env/lib/python3.8/site-packages/ee/oauth.py", line 111, in write_token
    os.open(credentials_path, os.O_WRONLY | os.O_CREAT, 0o600), 'w') as f:
PermissionError: [Errno 13] Permission denied: '/Users/my_username/.config/earthengine/credentials'

I also tried a fresh virtual environments and restarting the machine.

My earth engine account is white listed, and I am able to access https://code.earthengine.google.com/

3
  • I think this is a question best asked of Google because it relates to their licensing.
    – PolyGeo
    Commented Jun 5, 2021 at 23:26
  • Why are you using sudo to run the authentication command? It says right there in the error message that you don't have permission to read that file (because you ran it as root). PermissionError: [Errno 13] Permission denied: '/Users/my_username/.config/earthengine/credentials' Commented Jun 6, 2021 at 13:47
  • Thanks for your reply. I tried authenticating without sudo but still get a PermissionError after pasting in the verification code. I updated the question above with the traceback
    – nyquist
    Commented Jun 6, 2021 at 16:24

1 Answer 1

0

Solved this by changing permissions on the .config directory by running:

$ sudo chown -R my_username .config

Instructions found here: https://apple.stackexchange.com/questions/320682/ownership-of-the-config-folder-in-home-directory

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.