symerio / pgeocode

Postal code geocoding and distance calculation
https://pgeocode.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
231 stars 57 forks source link

pgeocode.py - ValueError: too many values to unpack (expected 3) #2

Closed michael-johnson-lucas closed 5 years ago

michael-johnson-lucas commented 5 years ago

Description

At the first run, whenever trying to download a new country, you get this error. A solution has been provided.

Pipfile

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pgeocode = '>=0.1.0'

[dev-packages]

[requires]
python_version = "3.7"

Error

Traceback (most recent call last):
  File ".../geocode.py", line 3, in <module>
    nomi = pgeocode.Nominatim('FR')
  File ".../lib/python3.7/site-packages/pgeocode.py", line 55, in __init__
    self._data_path, self._data = self._get_data(country)
  File ".../lib/python3.7/site-packages/pgeocode.py", line 71, in _get_data
    reader, encoding, compression = get_filepath_or_buffer(url)
ValueError: too many values to unpack (expected 3)

Change

File: pgeocode.py

-            reader, encoding, compression = get_filepath_or_buffer(url)
+            reader, encoding, compression, *rest = get_filepath_or_buffer(url)
rth commented 5 years ago

Thanks for the report!

Yes, there was a breaking change in pandas between versions 0.22 and 0.23 for pandas.io.common.get_filepath_or_buffer (https://github.com/pandas-dev/pandas/pull/19645#issuecomment-425191806).

The proposed fix is Python 3 only, something like the following should work with both 2 and 3 though,

reader, encoding, compression = get_filepath_or_buffer(url)[:3]

A pull request to fix it would be very much appreciated!

michael-johnson-lucas commented 5 years ago

Thank you very much.

This is very helpful and I really appreciate your work. FYI your library rocks 💯

rth commented 5 years ago

Thanks @michael-johnson-lucas ! Great to know that you find this library useful :)

zaro commented 5 years ago

Another workaround until new version is released is to fix pandas version to 0.22.0 .

rth commented 5 years ago

Thanks for the reminder.

Compatibility with pandas 0.23 should be fixed in the 0.1.1 release, please upgrade with,

pip install --upgrade --no-deps pgeocode