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/
sudo
but still get aPermissionError
after pasting in the verification code. I updated the question above with the traceback