Countryinfo package charmap error
mkaru opened this issue · comments
Hi!
I tried to use countryinfo package to match a country to it's continent but am still getting a charmap error message.
from countryinfo import CountryInfo
country = CountryInfo('France')
country.region()
File "...\AppData\Local\Programs\Python\Python37\lib\encodings\cp1257.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0xa1 in position 47: character maps to
PyCharm console:
sys.getdefaultencoding()
'utf-8'
So, why does it complain about CP1257 encoding?
Hi, I'm seeing the same problem
The code below got an error on windows 10.
python version 3.6.5
country = CountryInfo('Singapore')
File "...AppData\Local\Programs\Python\Python36\lib\site-packages\countryinfo\countryinfo.py", line 30, in init
country_info = json.load(open(file_path))
File "....AppData\Local\Programs\Python\Python36\Lib\json_init_.py", line 296, in load
return loads(fp.read(),
File "....AppData\Local\Programs\Python\Python36\Lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 49: character maps to
@Roman-Kasianenko ASAP you'll get update :)
Love this module, Porimol, but I'm encountering the same error and cannot load info for any countries. TIA
Windows 10
Anaconda distribution, Python 3.7.3
Windows Fix: modify line 30 of countryinfo.py
from: country_info = json.load(open(file_path))
to: country_info = json.load(open(file_path, encoding='utf-8'))
Resolved!
This is still an issue for me on windows 10.
Following advice here fixed it, though: https://python-forum.io/Thread-Countryinfo-package-charmap-error
hey @oosena , can you please install from source code? and let's report what happened.