GIScience / orstools-qgis-plugin

Plugin for QGIS with a set of tools to use openrouteservice API´s, based on openstreetmap
https://plugins.qgis.org/plugins/ORStools/
MIT License
98 stars 31 forks source link

Encoding issues on Mac OSX for metadata.txt #91

Closed gillyjuwa closed 5 years ago

gillyjuwa commented 5 years ago

Here's what I did


Here's what I got


Here's what I was expecting


Here's what I think could be improved

gillyjuwa commented 5 years ago

Hi team,

Please would you help me resolve the issues with installing and running ORS Tools. I've tried installing from the QGIS plugin repository AND by downloading the zip file and keep getting the following error: Couldn't load plugin 'ORStools'

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 155: ordinal not in range(128) Traceback (most recent call last): File "/Applications/QGIS3.6.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in loadPlugin import(packageName) File "/Applications/QGIS3.6.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ORStools/init.py", line 59, in METADATA.read(os.path.join(BASE_DIR, 'metadata.txt')) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 697, in read self._read(fp, filename) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 155: ordinal not in range(128)

Python version: 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] QGIS version: 3.6.0-Noosa Noosa, exported

Python Path: /Applications/QGIS3.6.app/Contents/MacOS/../Resources/python /Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python /Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins /Applications/QGIS3.6.app/Contents/MacOS/../Resources/python/plugins /Library/Frameworks/SQLite3.framework/Versions/E/Python/3.6 /Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6 /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages /Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python

Kind regards

Gillian

nilsnolde commented 5 years ago

Looks very much you have encoding problems. Seems a little weird, since this Python 3.x, which should default strings to UTF-8. Anyways, might be the configparser has problems (on Mac only? After 800 downloads this is the first I hear about it).

I patched real quick. Can you please try branch hotfix-#91-encoding_problems? It's the ZIP, but seems like you know what to do with it. Please let me know if this fixed your issue.

gillyjuwa commented 5 years ago

Dear Nils,

Thank you so much for your prompt reply.

I’m still not having any luck but I suspect it is as much due to my ignorance of coding as anything else.

I’ve tried installing the patch from the link and reinstalling ORS both from the plugin manager and the zip file.

I’ve also tried loading the plugin on different versions of QGIS (QGIS3 Madeira; QGIS 3.6 Noosa; and QGIS 2.18 Palma)

Would you please walk me through what I should be doing step by step.

I would like to use it for a health service access paper I’m writing as part of my Phd.

Kind regards

Gillian

On 7 Mar 2019, at 5:53 am, Nils notifications@github.com wrote:

Looks very much you have encoding problems. Seems a little weird, since this Python 3.x, which should default strings to UTF-8. Anyways, might be the configparser has problems (on Mac only? After 800 downloads this is the first I hear about it).

I patched real quick. Can you please try branch hotfix-#91-encoding_problems https://github.com/nilsnolde/orstools-qgis-plugin/archive/hotfix-%2391-encoding_problems.zip? It's the ZIP, but seems like you know what to do with it. Please let me know if this fixed your issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nilsnolde/orstools-qgis-plugin/issues/91#issuecomment-470292585, or mute the thread https://github.com/notifications/unsubscribe-auth/AuCdLge1hn7NR5CqxsOMR7djXeL7w6Syks5vUDjzgaJpZM4bgO4D.

nilsnolde commented 5 years ago

What, still the same error? And you tried the patched zip file, you're sure? You have to uninstall and re-install the new patch with the zip. Can you pls paste the error output again?

gillyjuwa commented 5 years ago

Hi Nils,

Sorry to cause problems

When I tried to install the patch from the zip file I get this message:

An error occurred during execution of following code: pyplugin_installer.instance().installFromZipFile(r'/Users/gillianjean/Downloads/orstools-qgis-plugin-hotfix-91-encoding_problems.zip')

traceback.print_exception() failed Python version:

QGIS version: 3.6.0-Noosa 'Noosa', exported

Python path:

When I try and install either through the plug in manager or through the zip file I get this message:

Couldn't load plugin 'ORStools' UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 155: ordinal not in range(128)

Traceback (most recent call last): File "/Applications/QGIS3.6.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 309, in loadPlugin import(packageName) File "/Applications/QGIS3.6.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 672, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "/Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ORStools/init.py", line 59, in METADATA.read(os.path.join(BASE_DIR, 'metadata.txt')) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 697, in read self._read(fp, filename) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py", line 1015, in _read for lineno, line in enumerate(fp, start=1): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 155: ordinal not in range(128)

Python version: 3.6.6 (v3.6.6:4cf1f54eb7, Jun 26 2018, 19:50:54) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] QGIS version: 3.6.0-Noosa Noosa, exported Python Path:

/Applications/QGIS3.6.app/Contents/MacOS/../Resources/python /Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python /Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins /Applications/QGIS3.6.app/Contents/MacOS/../Resources/python/plugins /Library/Frameworks/SQLite3.framework/Versions/E/Python/3.6 /Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6 /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages /Users/gillianjean/Library/Application Support/QGIS/QGIS3/profiles/default/python /Users/gillianjean/Documents/PhD/Rural and Remote Health What doesn’t make sense …..and this is why I think its probably something I’ve done….. the first time I tried to load openroutservice it loaded fine. I requested an API and when I tried to run the query it all disappeared and hasn’t worked since.

Could it be that I exceeded the free quota and so I’ve been locked out?

I’ve sent an email to your support team to ask about batch processing cost, bearing in mind I am a PhD student so by definition have little money!

It could also be that what I am asking openrouteservice to do is not realistic. I want to calculate shortest travel time from population centroid (point geometry latitude and longitude) to nearest health clinic. Problem is there are 55000 population points and 250 clinics. I only want the distance from each centroid to the nearest clinic. I was hoping that open route service would be the right software to use.

Kind regards

Gillian

On 7 Mar 2019, at 5:53 am, Nils notifications@github.com wrote:

Looks very much you have encoding problems. Seems a little weird, since this Python 3.x, which should default strings to UTF-8. Anyways, might be the configparser has problems (on Mac only? After 800 downloads this is the first I hear about it).

I patched real quick. Can you please try branch hotfix-#91-encoding_problems https://github.com/nilsnolde/orstools-qgis-plugin/archive/hotfix-%2391-encoding_problems.zip? It's the ZIP, but seems like you know what to do with it. Please let me know if this fixed your issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nilsnolde/orstools-qgis-plugin/issues/91#issuecomment-470292585, or mute the thread https://github.com/notifications/unsubscribe-auth/AuCdLge1hn7NR5CqxsOMR7djXeL7w6Syks5vUDjzgaJpZM4bgO4D.

nilsnolde commented 5 years ago

You're not loading the new patch version. I patched only this line of code (it's in your error):

METADATA.read(os.path.join(BASE_DIR, 'metadata.txt'))

You'll have to uninstall the ORS Tools plugin that you installed from the plugin manager. And install the ZIP verison I linked above! That line has to read

METADATA.read(os.path.join(BASE_DIR, 'metadata.txt'), encoding='utf-8')

For the rest: your problem is not your fault. There's some shit going on with your encoding on your system, but it's beyond me why it would do that. The last resort is to re-install QGIS. That's not normal behavior.

50000 x 250 you'll calculate within 3 days on the free quota and the matrix API. I really don't recommend using QGIS for that, but you can try.

nilsnolde commented 5 years ago

Ah now I see. That was confusing. No, that's not how you install the ZIP package from Github! Pls read my README.md. You have to extract the ZIP and zip up the ORSTools subdirectory.

gillyjuwa commented 5 years ago

Hi Nils, So I extracted the ZIP and then zipped up the ORSTools subdirectory and then installed from that. It says it has installed succesfully but does not appear on the plugins drop down menu as per You Tube demo. I have tried using the matrix api through the web and ......no luck! Tried running a small batch.

It must have something to do with the daily limits on the API, can we override that and is there a step by step tutorial to get me through this?

Kind regards

Gillian

nilsnolde commented 5 years ago

Did you activate the plugin in the Plugin Manager? It will definitely show up in the toolbar or in the Web (not the Plugin) menu, I just tried the exact same zip myself. What is a You Tube demo?

Of course, you can our Python lib if QGIS doesn't work for you. I'm afraid I can't help you from here on. It's all there, you just need to make it work yourself.

And it definitely has nothing to do with daily limits.