I'm having a hard time initializing GEE in QGIS. I've tried this on many different machines but no luck.
I've successfully installed Google Earth Engine in the QGIS plugin repository, but when it starts I'm prompted with this error message:
TypeError: get_authorization_url() missing 1 required positional argument: 'code_challenge'
Traceback (most recent call last):
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 230, in get_persistent_credentials
tokens = json.load(open(oauth.get_credentials_path()))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\hogan/.config/earthengine/credentials'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 19, in init
ee.Initialize()
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\__init__.py", line 114, in Initialize
credentials = data.get_persistent_credentials()
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 241, in get_persistent_credentials
'Please authorize access to your Earth Engine account by '
ee.ee_exception.EEException: Please authorize access to your Earth Engine account by running
earthengine authenticate
in your command line, and then retry.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python\qgis\utils.py", line 334, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\__init__.py", line 25, in classFactory
from .ee_plugin import GoogleEarthEnginePlugin
File "C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_plugin.py", line 26, in
ee_plugin.ee_auth.init()
File "C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 21, in init
authenticate()
File "C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 32, in authenticate
auth_url = ee.oauth.get_authorization_url()
TypeError: get_authorization_url() missing 1 required positional argument: 'code_challenge'
Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS version: 3.16.1-Hannover Hannover, b381a90dca
Python Path:
C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python
C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python/plugins
C:\PROGRA~1\QGIS3~1.16\apps\Python37
C:\PROGRA~1\QGIS3~1.16\apps\Python37\Scripts
C:\Program Files\QGIS 3.16\bin\python37.zip
C:\PROGRA~1\QGIS3~1.16\apps\Python37\DLLs
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib
C:\Program Files\QGIS 3.16\bin
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\win32
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\Pythonwin
C:/Users/hogan/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows
When I've tried to troubleshoot this and manually import in the Python Console, I'm able to import ee successfully, print the version number, and then when I run ee.Authenticate()
it sends me to the page to copy the link – HOWEVER no dialog box returns for me to enter that authorization code, and the system seems to time out. See below:
print(ee.__version__)
0.1.224
ee.Authenticate()
To authorize access needed by Earth Engine, open the following URL in a web browser and follow the instructions. If the web browser does not start automatically, please manually browse the URL below.
https://accounts.google.com/o/oauth2/auth?client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&code_challenge=plLB7m2RVrMuL4tLJn9tyYmTrd4IgHw80v7VpwDJs6E&code_challenge_method=S256
The authorization workflow will generate a code, which you should paste in the box below.
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\__init__.py", line 86, in Authenticate
oauth.authenticate(authorization_code, quiet, code_verifier)
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\oauth.py", line 233, in authenticate
_obtain_and_write_token(None, code_verifier) # Will prompt for auth_code.
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\oauth.py", line 137, in _obtain_and_write_token
auth_code = input('Enter verification code: ')
RuntimeError: input(): lost sys.stdin
ee.Initialize()
Traceback (most recent call last):
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 230, in get_persistent_credentials
tokens = json.load(open(oauth.get_credentials_path()))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\hogan/.config/earthengine/credentials'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\__init__.py", line 114, in Initialize
credentials = data.get_persistent_credentials()
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 241, in get_persistent_credentials
'Please authorize access to your Earth Engine account by '
ee.ee_exception.EEException: Please authorize access to your Earth Engine account by running
earthengine authenticate
in your command line, and then retry.
import ee
print(ee.__version__)
0.1.224
ee.Authenticate()
To authorize access needed by Earth Engine, open the following URL in a web browser and follow the instructions. If the web browser does not start automatically, please manually browse the URL below.
https://accounts.google.com/o/oauth2/auth?client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&code_challenge=_U4vCbBK3y96M4NCHviaxUyuuSOtaXf_z3USrh6xucA&code_challenge_method=S256
The authorization workflow will generate a code, which you should paste in the box below.
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\__init__.py", line 86, in Authenticate
oauth.authenticate(authorization_code, quiet, code_verifier)
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\oauth.py", line 233, in authenticate
_obtain_and_write_token(None, code_verifier) # Will prompt for auth_code.
File "C:\Users\hogan\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\oauth.py", line 137, in _obtain_and_write_token
auth_code = input('Enter verification code: ')
RuntimeError: input(): lost sys.stdin
Anyone else had this problem or know of a workaround?
Best Answer
I face the same problem at the beginning, but after making several attempts, finally, I made it. I list the attempts I made here, hope it will help you: In the beginning, I installed GEE plugin version 0.0.3 in QGIS version 3.16.2-Hannover, then it does not pop-up the interface which not asking for authentication, so I try to download the newest plugin version https://drive.google.com/uc?export=download&id=1x8QCQ-5CzjQEk-cNEyMU87Xz5S8LaR7s (from Github https://github.com/gee-community/qgis-earthengine-plugin/issues/76)
conda install earthengine-api
and then runearthengine authenticate
.My QGIS is the standalone one.