`search_fuzzy` fails for 'England' in v22.3.5
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
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)
Whilst waiting for new version to be released, this worked for me using "England": pip install pycountry==20.7.3
This is still happening. Any updates on fixing the issue?
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.
Broken for "Wales" too (returns Australia), but works in the aforementioned 20.7.3.
Still broken (and the same fix still works) now also.
ANy news on when this will be fixed?
This is resolved as of 23.12.7 release you can upgrade using
pip install pycountry --upgrade