gee-community / qgis-earthengine-plugin

Integrates Google Earth Engine and QGIS using Python API
http://qgis-ee-plugin.appspot.com
MIT License
454 stars 116 forks source link

Push new version to support Python 3.10 #109

Closed XavierCLL closed 2 years ago

XavierCLL commented 2 years ago

Push new minor version specially for this fix 38c25d5d41d6466c65325243974074d1839608b1 to support operation systems and new versions of Qgis with Python >= 3.10. Issue related #105

gena commented 2 years ago

I will probably then drop support for Python 3.7 as well.

And should it be Python 3.10 or 3.9.5? It looks like the long-term release of QGIS 3.22.3-Białowieża is based on Python 3.9.5, it would be nice to have it working as well probably.

XavierCLL commented 2 years ago

The solution works with the latest versions of Python and the old ones (that I tested), I tested both Qgis versions one with Python 3.9 and the other with Python 3.10, and both work fine.

gena commented 2 years ago

Great!

Ok, I've repackaged and uploaded (as experimental) v0.0.5 with http2 changes and with the latest version of the EE lib.

Now it's time to test if this works in different OSes and QGIS versions. The minimum QGIS requirements are the same (3.8).

gena commented 2 years ago

@XavierCLL @SiggyF, can you check if https://plugins.qgis.org/plugins/ee_plugin/version/0.0.5/ works on Ubuntu and macOS?

Delete the previous version first and delete EE credentials (~/.config/earthengine/...).

XavierCLL commented 2 years ago

I've found and fixed two issues: 2c8d5d8dc78aa69368ef9cfe56d2da61a2f7ddf9 and 0f81f76872549c1cb6e600d4f22c4b732505cfaf

I've tested the package v0.0.5 with the previous patches, it works great on:

ArchLinux:

gena commented 2 years ago

Great!

Fixes look fine, I will repackage everything, re-upload v0.0.5, and will test on Windows. If everything works fine - will push this as the last release version, but won't warn people to upgrade v0.0.4 > v0.0.5 as this is a minor release as, everything should work fine for those who are authenticated.

XavierCLL commented 2 years ago

Hi @gena I've realized that the version that you uploaded 0.0.5 doesn't have the fixes I made in the previous comment, those are important for the proper functioning of the plugin (mainly for python 3.10), could you please upload a minor release like 0.0.5a with these fixes? thanks!

XavierCLL commented 2 years ago

I saw that the version 0.0.5 is an experimental version, a kind reminder to launch the official version 0.0.5 with these fixes when you can, thanks

gena commented 2 years ago

Correct, I did not push 0.0.5 as an official release, but probably it makes sense.

Though I'm not sure it is necessary to push existing users to upgrade as the 0.0.4 seems to work fine once authentication was done before.

gena commented 2 years ago

Ok, @XavierCLL, I've re-uploaded 0.0.5 without experimental and, hopefully, added all fixes - please check. If everything works fine - I will release and tag 0.0.5 on GitHub

XavierCLL commented 2 years ago

Perfect, thanks

PedroVenancio commented 2 years ago

Hi @gena

I'm getting this error after upgrade from 0.0.4 to 0.0.5

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

ImportError: cannot import name 'GoogleEarthEnginePlugin' from 'ee_plugin.ee_plugin' (C:\Users/Agif/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_plugin\__init__.py) 
Traceback (most recent call last):
  File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 423, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "C:\Users/Agif/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\__init__.py", line 65, in classFactory
    from .ee_plugin import GoogleEarthEnginePlugin
ImportError: cannot import name 'GoogleEarthEnginePlugin' from 'ee_plugin.ee_plugin' (C:\Users/Agif/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\ee_plugin\ee_plugin\__init__.py)

Python version: 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] 
QGIS version: 3.22.7-Białowieża Białowieża, 5a65627a 

Any hint? Thanks!

gena commented 2 years ago

Thanks for reporting, @PedroVenancio! Investigating ...

gena commented 2 years ago

@PedroVenancio, can you try uninstalling/reinstalling v0.0.5?

PedroVenancio commented 2 years ago

@gena I did it

imagem

and get back to 0.0.4.

No problem with this version.

gena commented 2 years ago

0.0.5 should work as well (has latest EE library), was just updated.

If 0.0.4 breaks - try switching to 0.0.5

XavierCLL commented 2 years ago

Hi @PedroVenancio,

That is weird, that line of the error wasn't changed between the versions 0.0.5 and 0.0.4. I tested the new version in Windows and works fine, please try updating to 0.0.5 and restart Qgis, I guess it is due to a problem with the differences of external libs because @gena has updated the external libs in this latest version and Qgis load it at startup.

gena commented 2 years ago

It looks like the new 0.0.5 is not approved on qgis yet

gena commented 2 years ago

@XavierCLL, it also looks like we did not test 0.0.5 well yet, getting error when .config/earthengine/authentication is removed:

image

PedroVenancio commented 2 years ago

Hi @XavierCLL and @gena

I was waiting to the plugin's approval, but I've downloaded it from https://plugins.qgis.org/plugins/ee_plugin/version/0.0.5/ and installed manually and it seems fixed! No error now! Had you changed something @gena ?

Thanks!

giswqs commented 2 years ago

As as as I know, Earth Engine (v0.1.316) does not work with Python. 3.10. You can authenticate it, but it fails ee.Initialize(). I am not sure how you made it work with Python 3.10.

@tylere @jdbcode

conda create -n gee python
conda activate gee
conda install mamba -c conda-forge
mamba install geemap -c conda-forge
import ee
ee.Authenticate(auth_mode='notebook')
ee.Initialize()

image

gena commented 2 years ago

I'm testing it locally with QGIS-3.18/Python 3.7.0, and still see the Authentication error from earthengine_api-0.1.316-py3.7.egg-info, investigating further, the following code reproduces the error:

import ee
pkce = ee.oauth._nonce_table('code_verifier')
code_verifier = pkce['code_verifier']
auth_url = ee.oauth.get_authorization_url(pkce['code_challenge'], None)
print(auth_url)

image

gena commented 2 years ago

Switched v0.0.5 back to Experimental for now

XavierCLL commented 2 years ago

@gena @PedroVenancio yeah confirmed It worked 2 weeks ago, maybe Google change something for the oauth, it requires more investigation.

@giswqs for python 3.10 you can fix that running that code like this:

import ee
import httplib2
ee.Authenticate(auth_mode='notebook')
ee.Initialize(http_transport=httplib2.Http())
giswqs commented 2 years ago

@XavierCLL Thanks for the workaround. It appears that this issue has existed for a few months now. It would be great if this issue can be fixed by Google directly. Not many people know this workaround.

gena commented 2 years ago

I'm currently trying to find a way to authenticate properly. The best would be to use ee.Authenticate(), but currently, it fails in QGIS because it requires gcloud CLI.

gena commented 2 years ago

I think this can be considered fixed, the new version is in QGIS plugins repo and approved