pycountry icon indicating copy to clipboard operation
pycountry copied to clipboard

`search_fuzzy` fails for 'England' in v22.3.5

Open clarkedb opened this issue 3 years ago • 2 comments

Python Version: 3.9.13 pycountry Version: 22.3.5

'England' is the example for search_fuzzy and it isn't working in the latest version of pycountry on python 3.9. It raises a LookupError instead of returning the GB country.

The example from the documentation for search_fuzzy is

import pycountry
pycountry.countries.search_fuzzy('England')

Expected output:

In [2]: pycountry.countries.search_fuzzy('England')
Out[2]: [Country(alpha_2='GB', alpha_3='GBR', name='United Kingdom', numeric='826', official_name='United Kingdom of Great Britain and Northern Ireland')]

Actual ouput:

In [2]: pycountry.countries.search_fuzzy('England')
---------------------------------------------------------------------------
LookupError                               Traceback (most recent call last)
<ipython-input-23-b4bbc1495b32> in <module>
----> 1 pycountry.countries.search_fuzzy('England')

/usr/local/lib/python3.9/site-packages/pycountry/__init__.py in search_fuzzy(self, query)
     94 
     95         if not results:
---> 96             raise LookupError(query)
     97 
     98         results = [

LookupError: england

clarkedb avatar Aug 01 '22 14:08 clarkedb

The removal of UK's subdivisions was an accidental change in the upstream iso-codes distribution and should go away when pycountry updates to version 4.10.0 (or greater) of iso-codes.

(also see #94 for a previous report of this issue)

n-st avatar Aug 02 '22 00:08 n-st

Whilst waiting for new version to be released, this worked for me using "England": pip install pycountry==20.7.3

jjcfrancisco avatar Aug 09 '22 10:08 jjcfrancisco

This is still happening. Any updates on fixing the issue?

theholy7 avatar Feb 28 '23 14:02 theholy7

iso-codes is now on version 4.1 https://salsa.debian.org/iso-codes-team/iso-codes/-/releases

This needs to be updated.

Edit - oh, it is updated, but this is still broken.

theelous3 avatar Mar 13 '23 05:03 theelous3

Broken for "Wales" too (returns Australia), but works in the aforementioned 20.7.3.

MikeFE avatar Mar 14 '23 23:03 MikeFE

Still broken (and the same fix still works) now also.

ostracon avatar May 18 '23 14:05 ostracon

ANy news on when this will be fixed?

madt2709 avatar Aug 11 '23 17:08 madt2709

This is resolved as of 23.12.7 release you can upgrade using

pip install pycountry --upgrade

nschimmoller avatar Dec 08 '23 19:12 nschimmoller