Skip to content

IPinfo 4.4.0 version Unicodeerror on initializing handler. #72

@abdullahdevrel

Description

@abdullahdevrel

Error Description

This error was found on a Windows 10 environment.

import ipinfo
access_token = 'MY_ACCESS_TOKEN'
handler = ipinfo.getHandler(access_token)

This code triggers the following error:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    handler = ipinfo.getHandler(access_token)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\ipinfo\__init__.py", line 7, in getHandler
    return Handler(access_token, **kwargs)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\ipinfo\handler.py", line 68, in __init__
    self.countries_currencies = handler_utils.read_json_file(
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\ipinfo\handler_utils.py", line 107, in read_json_file
    countries_json = f.read()
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\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 0x8f in position 299: character maps to <undefined>

Temporary Fix

Step 1

Uninstall the IPinfo module version 4.4.0 with the following command:

pip uninstall ipinfo

Step 2

Install the previous stable release IPinfo version: 4.3.1 with the following command:

pip install ipinfo==4.3.1

You can check if your python library version with the following command as well:

pip show ipinfo

Which will output the following:

Name: ipinfo
Version: 4.3.1
.....

Then you should be ready to go if you are not using the added functions from the version 4.4.0 such as:

  • country_flag
  • country_currecny
  • continent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions