Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qgis-earthengine-plugin cannot be use #35

Closed
dongjief opened this issue Dec 5, 2019 · 16 comments
Closed

qgis-earthengine-plugin cannot be use #35

dongjief opened this issue Dec 5, 2019 · 16 comments
Labels
authentication Authentication problems

Comments

@dongjief
Copy link

dongjief commented Dec 5, 2019

Hi, I just met the problem, and the qgis-earthengine-plugin cannot be use.
When the plugin had been installed, the problem appeared.
My OS and QGIS version are Windows 10, QGIS 3.10 'A Coruña'.

I thought that it may be caused by different directory definition (/ or ), but when I change to the Mac, the same problem still appear.

The detailed information is showed as bellow.

Couldn't load plugin 'ee_plugin' due to an error when calling its classFactory() method

ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接 (The remote host forcibly close an existing connection)。
Traceback (most recent call last):
File "C:\Users\DongjieFu\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 218, in get_persistent_credentials
tokens = json.load(open(oauth.get_credentials_path()))
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\DongjieFu/.config/earthengine/credentials'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 19, in init
ee.Initialize()
File "C:\Users\DongjieFu\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee_init_.py", line 112, in Initialize
credentials = data.get_persistent_credentials()
File "C:\Users\DongjieFu\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 229, 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 "d:/Program Files/QGIS 3.10/apps/qgis/./python\qgis\utils.py", line 334, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin_init
.py", line 25, in classFactory
from .ee_plugin import GoogleEarthEnginePlugin
File "d:/Program Files/QGIS 3.10/apps/qgis/./python\qgis\utils.py", line 737, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_plugin.py", line 26, in
ee_plugin.ee_auth.init()
File "C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 21, in init
authenticate()
File "C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 45, in authenticate
'URL: ' + tiny_url(auth_url))
File "C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 27, in tiny_url
tinyurl = urllib.request.urlopen(apiurl + url).read()
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\urllib\request.py", line 543, in _open
'_open', req)
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\urllib\request.py", line 1345, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\urllib\request.py", line 1320, in do_open
r = h.getresponse()
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\http\client.py", line 1321, in getresponse
response.begin()
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\http\client.py", line 296, in begin
version, status, reason = self._read_status()
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\http\client.py", line 257, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "d:\Program Files\QGIS 3.10\apps\Python37\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS version: 3.10.0-A Coruña A Coruña, 6ffa89eb3e

Python Path:
d:/Program Files/QGIS 3.10/apps/qgis/./python
C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
d:/Program Files/QGIS 3.10/apps/qgis/./python/plugins
D:\Program Files\QGIS 3.10\bin\python37.zip
d:\Program Files\QGIS 3.10\apps\Python37\DLLs
d:\Program Files\QGIS 3.10\apps\Python37\lib
D:\Program Files\QGIS 3.10\bin
d:\Program Files\QGIS 3.10\apps\Python37
d:\Program Files\QGIS 3.10\apps\Python37\lib\site-packages
d:\Program Files\QGIS 3.10\apps\Python37\lib\site-packages\win32
d:\Program Files\QGIS 3.10\apps\Python37\lib\site-packages\win32\lib
d:\Program Files\QGIS 3.10\apps\Python37\lib\site-packages\Pythonwin
C:/Users/DongjieFu/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\DongjieFu\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows

@gena
Copy link
Collaborator

gena commented Dec 5, 2019

Could be some firewall issue, can you try:

  1. install ee python api separately from qgis by running conda install earthengine-api and then run earthengine authenticate and follow instructions, if that works then restart QGIS
  2. open tinyurl.com in a browser, this is used to shorten the auth url during plugin setup.

@GokulGeo
Copy link

GokulGeo commented Dec 5, 2019

Earth engine plugin works in 3.8 will it work in 3.10?

@gena
Copy link
Collaborator

gena commented Dec 5, 2019

@GokulGeo - it should, it was tested with 3.8 and 3.10.

@GokulGeo
Copy link

GokulGeo commented Dec 6, 2019

It is working fine in 3.10. I am totally a beginner in python, I hope there will be sample exercises in the future to explore in qgis.

@aguil77
Copy link

aguil77 commented Dec 16, 2019

Hi everyone, I have a similar problem, I thought it was a problem of SSL Certificates but they are already update and I cannot operate the plugin, the message is as follows:

Couldn't load plugin 'ee_plugin' due to an error when calling its classFactory() method

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (ssl.c:1045)
Traceback (most recent call last):
File "C:/PROGRA1/QGIS31.10/apps/qgis/./python\qgis\utils.py", line 334, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:/Users/DAI-7/AppData/Roaming/QGIS/QGIS3\profiles\GEE/python/plugins\ee_plugin_init
.py", line 25, in classFactory
from .ee_plugin import GoogleEarthEnginePlugin
File "C:/PROGRA1/QGIS31.10/apps/qgis/./python\qgis\utils.py", line 737, in import
mod = builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/DAI-7/AppData/Roaming/QGIS/QGIS3\profiles\GEE/python/plugins\ee_plugin\ee_plugin.py", line 26, in
ee_plugin.ee_auth.init()
File "C:/Users/DAI-7/AppData/Roaming/QGIS/QGIS3\profiles\GEE/python/plugins\ee_plugin\ee_auth.py", line 19, in init
ee.Initialize()
File "C:\Users\DAI-7\AppData\Roaming\QGIS\QGIS3\profiles\GEE\python\plugins\ee_plugin\extlibs_windows\ee_init
.py", line 123, in Initialize
ApiFunction.initialize()
File "C:\Users\DAI-7\AppData\Roaming\QGIS\QGIS3\profiles\GEE\python\plugins\ee_plugin\extlibs_windows\ee\apifunction.py", line 154, in initialize
signatures = data.getAlgorithms()
File "C:\Users\DAI-7\AppData\Roaming\QGIS\QGIS3\profiles\GEE\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 952, in getAlgorithms
return send
('/algorithms', {}, 'GET')
File "C:\Users\DAI-7\AppData\Roaming\QGIS\QGIS3\profiles\GEE\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 1762, in send

response, content = send_with_backoff()
File "C:\Users\DAI-7\AppData\Roaming\QGIS\QGIS3\profiles\GEE\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 1753, in send_with_backoff
url, method=opt_method, body=payload, headers=headers)
File "C:\Users\DAI-7\AppData\Roaming\QGIS\QGIS3\profiles\GEE\python\plugins\ee_plugin\extlibs_windows\google_auth_httplib2.py", line 198, in request
uri, method, body=body, headers=request_headers, **kwargs)
File "C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages\httplib2_init_.py", line 1514, in request
(response, content) = self.request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages\httplib2_init
.py", line 1264, in _request
(response, content) = self.conn_request(conn, request_uri, method, body, headers)
File "C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages\httplib2_init
.py", line 1187, in conn_request
conn.connect()
File "C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages\httplib2_init
.py", line 1013, in connect
self.sock = self._context.wrap_socket(sock, server_hostname=self.host)
File "C:\PROGRA1\QGIS31.10\apps\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\PROGRA1\QGIS31.10\apps\Python37\lib\ssl.py", line 850, in _create
self.do_handshake()
File "C:\PROGRA1\QGIS31.10\apps\Python37\lib\ssl.py", line 1108, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1045)

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS version: 3.10.0-A Coruña A Coruña, 6ffa89eb3e

Python Path:
C:/PROGRA1/QGIS31.10/apps/qgis/./python
C:/Users/DAI-7/AppData/Roaming/QGIS/QGIS3\profiles\GEE/python
C:/Users/DAI-7/AppData/Roaming/QGIS/QGIS3\profiles\GEE/python/plugins
C:/PROGRA1/QGIS31.10/apps/qgis/./python/plugins
C:\Program Files\QGIS 3.10\bin\python37.zip
C:\PROGRA1\QGIS31.10\apps\Python37\DLLs
C:\PROGRA1\QGIS31.10\apps\Python37\lib
C:\Program Files\QGIS 3.10\bin
C:\PROGRA1\QGIS31.10\apps\Python37
C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages
C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages\win32
C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages\win32\lib
C:\PROGRA1\QGIS31.10\apps\Python37\lib\site-packages\Pythonwin
C:/Users/DAI-7/AppData/Roaming/QGIS/QGIS3\profiles\GEE/python
C:\Users\DAI-7\AppData\Roaming\QGIS\QGIS3\profiles\GEE\python\plugins\ee_plugin\extlibs_windows

@SiggyF SiggyF added the authentication Authentication problems label Dec 17, 2019
@giswqs
Copy link
Member

giswqs commented Dec 24, 2019

@GokulGeo Here are examples.

@gena
Copy link
Collaborator

gena commented Dec 24, 2019

The first fix for this authentication type of error is to try authenticating using the command-line version of EE. Please follow https://developers.google.com/earth-engine/command_line and install EE Python API using Conda and then authenticate it via earthengine authenticate.

@giswqs nice to see examples for the plugin, but this is a bit off-topic here. I'd post this on the developers' forum.

@geomenke
Copy link

I am having similar issues getting the plugin to authenticate on my Windows 10 box. I have installed earthengine-api via OsGeo4W shell and Anaconda and successfully authenticated EE at the command prompt. However, when I paste the authentication code into the plugin window I always get the message below. I've tried it on ubuntu with similar results.. I have tried this on QGIS v3.12-1 and 3.10-4. Any guidance appreciated.

Couldn't load plugin 'ee_plugin' due to an error when calling its classFactory() method

ee.ee_exception.EEException: Server returned HTTP code: 404
Traceback (most recent call last):
File "C:/Users/Kurt Menke/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 19, in init
ee.Initialize()
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee_init_.py", line 123, in Initialize
ApiFunction.initialize()
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\apifunction.py", line 154, in initialize
signatures = data.getAlgorithms()
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 952, in getAlgorithms
return send_('/algorithms', {}, 'GET')
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 1797, in send_
'Server returned HTTP code: %d' % response.status)
ee.ee_exception.EEException: Server returned HTTP code: 404

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/OSGEO41/apps/qgis/./python\qgis\utils.py", line 334, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "C:/Users/Kurt Menke/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin_init
.py", line 25, in classFactory
from .ee_plugin import GoogleEarthEnginePlugin
File "C:/OSGEO4
1/apps/qgis/./python\qgis\utils.py", line 744, in import
mod = builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/Kurt Menke/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_plugin.py", line 26, in
ee_plugin.ee_auth.init()
File "C:/Users/Kurt Menke/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_auth.py", line 22, in init
ee.Initialize() # retry initialization once the user logs in
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee_init
.py", line 123, in Initialize
ApiFunction.initialize()
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\apifunction.py", line 154, in initialize
signatures = data.getAlgorithms()
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 952, in getAlgorithms
return send
('/algorithms', {}, 'GET')
File "C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows\ee\data.py", line 1797, in send_
'Server returned HTTP code: %d' % response.status)
ee.ee_exception.EEException: Server returned HTTP code: 404

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS version: 3.12.1-București București, 121cc00ff0

Python Path:
C:/OSGEO41/apps/qgis/./python
C:/Users/Kurt Menke/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/Kurt Menke/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/OSGEO4
1/apps/qgis/./python/plugins
C:\OSGEO41\apps\Python37
C:\OSGEO4
1\apps\Python37\Scripts
C:\OSGeo4W64\bin\python37.zip
C:\OSGEO41\apps\Python37\DLLs
C:\OSGEO4
1\apps\Python37\lib
C:\OSGeo4W64\bin
C:\OSGEO41\apps\Python37\lib\site-packages
C:\OSGEO4
1\apps\Python37\lib\site-packages\win32
C:\OSGEO41\apps\Python37\lib\site-packages\win32\lib
C:\OSGEO4
1\apps\Python37\lib\site-packages\Pythonwin
C:/Users/Kurt Menke/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\crayfish\gui..\pyqtgraph-0.10.0-py2.py3-none-any.whl
C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\DigitizingTools\tools
C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\DigitizingTools
C:\Users\Kurt Menke\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\ee_plugin\extlibs_windows

@gena
Copy link
Collaborator

gena commented Apr 15, 2020

Installing earthengine-api under QGIS python in parallel to QGIS EE plugin is a road to troubles, since calling import ee will be ambiguous - don't do that (uninstall it). Instead, install earthengine-api under some separate python/anaconda installation. There is no need to copy/paste code in this case, just authenticate using a separate python installation + earthengine-api, follow instructions, once earthengin-api is authenticated - a new file will be written in ~.config\earthengine\credentials. The EE plugin will pick up that file during QGIS start and will use to talk to EE.

@geomenke
Copy link

@gena Thanks for the feedback and help. Now I have a single installation of earthengine (anaconda) and see the ~.config\earthengine\credentials file. However, QGIS does not pick up on it. When QGIS launches the Authorization window opens instructing me to follow the instructions in the opened web page and paste the resulitng auth token here.
image

@gena
Copy link
Collaborator

gena commented Apr 15, 2020

That's weird,

what QGIS version are you using? - just saw it specified above

One option I'd think of is to uninstall the plugin and make sure there is nothing from the earthengine-api left in the QGIS directory.

This could be a new EE API issue as well.

... also the dialog text needs to be fixed 🙂

@gena
Copy link
Collaborator

gena commented Apr 15, 2020

So, try to:

  • Uninstall QGIS plugin
  • Start QGIS and type in Python console: import ee - this should fail

@geomenke
Copy link

I unistalled the plugin.
import ee failed at the python console
Checked my plugin folder and there is nothing related to ee there
Reinstalled the plugin and at that point can import ee at the console.
However, when I close QGIS and restart I get the Authorization message

@gena
Copy link
Collaborator

gena commented Apr 15, 2020

Hmm, I've just removed my auth file and tried to authenticate from QGIS on my machine as well ... everything worked. I've sent you an email, let's find out why this fails on your machine. This could be some firewall issue, but then authenticating using CLI would also fail.

@dongjief
Copy link
Author

Hi, Gena,

I can use the qgis-earthengine-plugin now.
The method I used was set a proxy command in Python Console of QGIS. It is shown as below.

import ee
import os
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:1081'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:1081'
ee.Initialize()

Then the plugin can be applied.

@gena
Copy link
Collaborator

gena commented Apr 16, 2020

It seems that 404 sometimes means that account is not fully whitelisted, I'll extend FAQ to include this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authentication Authentication problems
Projects
None yet
Development

No branches or pull requests

7 participants