porimol / countryinfo

A python module for returning data about countries, ISO info and states/provinces within them.
MIT License
143 stars 44 forks source link

Countryinfo package charmap error #3

Closed mkaru closed 4 years ago

mkaru commented 6 years ago

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?

Roman-Kasianenko commented 5 years ago

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

porimol commented 5 years ago

@Roman-Kasianenko ASAP you'll get update :)

ATidmore commented 5 years ago

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

brandonlammey commented 5 years ago

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'))

porimol commented 4 years ago

Resolved!

oosena commented 4 years ago

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

porimol commented 4 years ago

hey @oosena , can you please install from source code? and let's report what happened.