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 Earth Engine Plugin does not work on Mac #39

Closed
sahirpatel opened this issue Dec 19, 2019 · 27 comments
Closed

QGIS Earth Engine Plugin does not work on Mac #39

sahirpatel opened this issue Dec 19, 2019 · 27 comments
Labels
authentication Authentication problems

Comments

@sahirpatel
Copy link

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

urllib.error.URLError:
Traceback (most recent call last):
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/extlibs_darwin/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: '/Users/sahirpatel/.config/earthengine/credentials'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/ee_auth.py", line 19, in init
ee.Initialize()
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/extlibs_darwin/ee/init.py", line 112, in Initialize
credentials = data.get_persistent_credentials()
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/extlibs_darwin/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 "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/urllib/request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/http/client.py", line 956, in send
self.connect()
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/http/client.py", line 1392, in connect
server_hostname=server_hostname)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Applications/QGIS3.10.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 334, in _startPlugin
plugins[packageName] = package.classFactory(iface)
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/init.py", line 25, in classFactory
from .ee_plugin import GoogleEarthEnginePlugin
File "/Applications/QGIS3.10.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 744, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/ee_plugin.py", line 26, in
ee_plugin.ee_auth.init()
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/ee_auth.py", line 21, in init
authenticate()
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/ee_auth.py", line 48, in authenticate
ee.oauth._obtain_and_write_token(token.strip())
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/extlibs_darwin/ee/oauth.py", line 128, in _obtain_and_write_token
token = request_token(auth_code)
File "/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/extlibs_darwin/ee/oauth.py", line 79, in request_token
parse.urlencode(request_args).encode()).read().decode()
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/urllib/request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/urllib/request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError:

Python version: 3.7.3 (default, Mar 27 2019, 09:23:15) [Clang 10.0.1 (clang-1001.0.46.3)]
QGIS version: 3.10.1-A Coruña A Coruña, 1e6b1a3eda

Python Path:
/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/WaterNetAnalyzer-master
/Applications/QGIS3.10.app/Contents/MacOS/../Resources/python
/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins
/Applications/QGIS3.10.app/Contents/MacOS/../Resources/python/plugins
/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages
/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python37.zip
/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7
/Applications/QGIS3.10.app/Contents/Resources/python
/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages/geos
/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/lib-dynload
/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python
/Users/sahirpatel/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ee_plugin/extlibs_darwin

@sahirpatel sahirpatel changed the title QGIS Earth Engine Plugin will not work on Mac QGIS Earth Engine Plugin does not work on Mac Dec 19, 2019
@jerrod-lessel
Copy link

Pretty sure thats the same error I got, I just double clicked the Install Certificates.command file in my python folders and it solved the issue.

@sahirpatel
Copy link
Author

Hi Jerrod, thankyou for your response, where exactly can I find this command?

@jerrod-lessel
Copy link

For me it is in the python folders where the applications are.

@sahirpatel
Copy link
Author

I have tried it and the problem still persists.

@jerrod-lessel
Copy link

Huh, that's odd because I just checked my error and it was the same. I don't know what else I did that could have affected this. I'm sorry I couldn't help much then.

@gena
Copy link
Collaborator

gena commented Dec 20, 2019

@sahirpatel, can you make sure that you run it on a proper Python that is used by QGIS, as mentioned in https://github.com/gee-community/qgis-earthengine-plugin/blob/master/README.md#faq?

@jerrod-lessel
Copy link

Ah I did that as well, that must have been the additional step for what was needed.

@gena gena added the authentication Authentication problems label Dec 24, 2019
@spatialthoughts
Copy link

I was in touch with @sahirpatel and we fixed this issue by running earthengine authenticate. The following worked for him

Open Terminal and enter following commands

sudo pip3 install earthengine-api
earthengine authenticate

Maybe add this to the FAQ for mac users? This will be easier for most QGIS mac users than installing via Conda

@SiggyF
Copy link
Collaborator

SiggyF commented Feb 6, 2020

sudo pip3 install earthengine-api
earthengine authenticate

Maybe add this to the FAQ for mac users? This will be easier for most QGIS mac users than installing via Conda

There is a variety of types of python installations for the mac:

  • Native python version
  • Homebrew (package manager)
  • Macports (package manager)
  • Anaconda (python package manager)
    Each of installations can be used together with environments:
  • virtualenv
  • conda environments
  • pipenv

When you do sudo pip3 install the earthengine package might end up in the system package, which is generally not you want, because it is also used by OSX itself.

@M-Rick
Copy link

M-Rick commented Feb 6, 2020

Just tried and didn't work. pip3 installed well the earthengine-api and the earthengine authenticate command did worked well. I could associate it to my Google Account. But back in QGIS, enabling the Google Earth Engine plugin, it requested a new authentification again and didn't succeed with the same bug again.

sudo /Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 install earthengine-api

If I setup in QGIS a custom path
/Library/Frameworks/Python.framework/Versions/3.6/bin:/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/bin
the Google Earth Engine plugin won't request authentification, but I get directly the error window.
No better success.

@ghost
Copy link

ghost commented Mar 15, 2020

I seem to be getting similar authentication issues on mac. Get the following when using the earthengine authenticate command via terminal (after the sudo install)

import tensorflow.compat.v1 as tf
ModuleNotFoundError: No module named 'tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1319, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1230, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1276, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1225, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1004, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 944, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1399, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/earthengine", line 11, in
load_entry_point('earthengine-api==0.1.215', 'console_scripts', 'earthengine')()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/cli/eecli.py", line 94, in main
_run_command()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/cli/eecli.py", line 81, in _run_command
dispatcher.run(args, config)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/cli/commands.py", line 327, in run
self.command_dict[vars(args)[self.dest]].run(args, config)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/cli/commands.py", line 360, in run
ee.Authenticate(**args_auth)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/init.py", line 86, in Authenticate
oauth.authenticate(authorization_code, quiet, code_verifier)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/oauth.py", line 233, in authenticate
_obtain_and_write_token(None, code_verifier) # Will prompt for auth_code.
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/oauth.py", line 139, in _obtain_and_write_token
token = request_token(auth_code.strip(), code_verifier)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ee/oauth.py", line 82, in request_token
response = request.urlopen(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1362, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1322, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>

@giaco51
Copy link

giaco51 commented Apr 28, 2020

I am having the exact same problem on my MBP/10.13.6. Funny, I installed Python 3.7 Install Certificates.command and Update Shell Profile.command, which is what QGIS 3.10 uses and re-installed EE plugin after a re-start. Same problem. When the same action was performed on my iMac/10.12, it worked perfectly! Please help!

@rsprabha
Copy link

rsprabha commented May 4, 2020

I am having the same authentication problem. Has there been a fix for this?

@gena
Copy link
Collaborator

gena commented May 4, 2020

@rsprabha did it work before? Did you follow steps in https://github.com/gee-community/qgis-earthengine-plugin/blob/master/README.md#faq? Does the command-line version of EE, installed in the main system Python instead of in QGIS, work?

@gena
Copy link
Collaborator

gena commented May 4, 2020

Also, check if you can access and login using Code Editor: http://code.earthengine.google.com. Sometimes accounts are not enabled, which will also result in errors in QGIS.

@rsprabha
Copy link

rsprabha commented May 4, 2020

GEE Code editor works...
Also worked though the links and authenticated by the python shell
And got
print(ee.String('Hello World from EE!').getInfo())
Thanks

@ghost
Copy link

ghost commented May 5, 2020

The code editor worked for me. Thanks Gena.

@asuhag
Copy link

asuhag commented May 17, 2020

Had the same error. The following worked for me.

  • Uninstall earthengine plugin from qgis.
  • install earth engine via your terminal -- pip install earthengine-api
  • open python in your terminal and do the following

import ee
ee.Authenticate()

This will lead you to the browser. Copy the token and paste in the terminal.
If that works, you should see this "Successfully saved authorization token."
Exit python from your terminal

exit()

  • Open qgis and install the plugin.

@aadi2712
Copy link

aadi2712 commented Oct 6, 2020

installing earth engine from the terminal first and then through plugin worked for me. Thanks asuhag

@M-Rick
Copy link

M-Rick commented Oct 6, 2020

import ee

I get an error.

Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ee
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ee/__init__.py", line 1, in <module>
    from .main import main
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ee/main.py", line 10, in <module>
    import StringIO
ModuleNotFoundError: No module named 'StringIO'

@asuhag
Copy link

asuhag commented Oct 6, 2020

M-Rick, Try this

nahamsec/JSParser#18 (comment)

@gena
Copy link
Collaborator

gena commented Oct 6, 2020

@M-Rick, in most of the cases these errors occur due to conflicts in local installations of python packages. Make sure you have the latest version of earthengine-api package installed. Or try uninstalling earthengine-api from your python environment so that QGIS EE plugin can use it's embedded version, 0.1.226.

Did you install earthengine-api package before in your python environment? I'm not sure if QGIS shares python environment on MacOS.

@nelsonag96
Copy link

I'm having the same problem, I've tried everything, but it doesn't seem to work. I get this error when I type the 'import ee' on the QGIS python console:
Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'ee'

@gena
Copy link
Collaborator

gena commented Nov 28, 2020

@nelsonag96 can you check if the following version works for you (install from a zip): #70 (comment)?

@nelsonag96
Copy link

@gena Yes, I could, thank you! However, when I try to authenticate 'earthengine authenticate' I get the following error:
Traceback (most recent call last):
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/code.py", line 63, in runsource
code = self.compile(source, filename, symbol)
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 171, in call
return _maybe_compile(self.compiler, source, filename, symbol)
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 100, in _maybe_compile
raise err1
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 87, in _maybe_compile
code1 = compiler(source + "\n", filename, symbol)
File "/Applications/QGIS.app/Contents/MacOS/../Resources/python/codeop.py", line 136, in call
codeob = compile(source, filename, symbol, self.flags, 1)
File "", line 1
earthengine authenticate
^
SyntaxError: invalid syntax

@gena
Copy link
Collaborator

gena commented Nov 28, 2020

Are you trying to run earthengine authenticate in the QGIS Python console? Try in the OS terminal.

@gena
Copy link
Collaborator

gena commented Jan 7, 2021

This should work, fixed by #82

@gena gena closed this as completed Jan 7, 2021
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