# encodings.CodecRegistryError (attempt to get data from weather station via API)

**URL:** <https://forum.inductiveautomation.com/t/encodings-codecregistryerror-attempt-to-get-data-from-weather-station-via-api/40546>\
**Category:** Maker\
**Created:** [November 11, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/encodings-codecregistryerror-attempt-to-get-data-from-weather-station-via-api/40546 "2020-11-11T16:54:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kb5won](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kb5won/32/4967_2.png) [@kb5won](https://forum.inductiveautomation.com/u/kb5won)\
**Post date:** [November 11, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/encodings-codecregistryerror-attempt-to-get-data-from-weather-station-via-api/40546/1 "2020-11-11T16:54:44Z")

</div>

I’ve installed the API helper functions provided by the weather station I’m trying to connect to. I did this using ‘pip install ambient\_api==1.5.1’ and creating a symlink from …/ignition/user-lib/pylib/site-packages to the jython install folder’s site-packages.

First problem:  
when I try to test code using igniton’s script console, it seems to be using a local cache copy of everything, well almost everything. I don’t think it brings over a copy of the environment variables needed and maybe more, so I get errors related to that— so next I tried to create a button in perspective, with a script–

Second problem:  
within the perspective button script, I have:

```auto
	from ambient_api.ambientapi import AmbientAPI
	import time
	
	api = AmbientAPI()
	devices = api.get_devices()
	
	device = devices[0]
	
	time.sleep(1) #pause for a second to avoid API limits
	
	print(device.get_data())

```

when I click the button, I get the following errors

```auto
com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:runAction>", line 2, in runAction
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/ambient_api/ambientapi.py", line 4, in <module>
    import requests
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/ __init__.py", line 120, in <module>
    from . import utils
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/utils.py", line 27, in <module>
    from ._internal_utils import to_native_string
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/_internal_utils.py", line 11, in <module>
    from .compat import is_py2, builtin_str, str
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/compat.py", line 31, in <module>
    import json
  File "/usr/local/bin/ignition/user-lib/pylib/json/ __init__.py", line 108, in <module>
    from .decoder import JSONDecoder
  File "/usr/local/bin/ignition/user-lib/pylib/json/decoder.py", line 24, in <module>
    NaN, PosInf, NegInf = _floatconstants()
  File "/usr/local/bin/ignition/user-lib/pylib/json/decoder.py", line 18, in _floatconstants
    _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
  File "user-lib/pylib/encodings/ __init__.py", line 142, in search_function
    raise CodecRegistryError,\
encodings.CodecRegistryError: incompatible codecs in module "encodings.hex_codec" (/usr/local/bin/ignition/user-lib/pylib/encodings/hex_codec.py)

	caused by org.python.core.PyException
Traceback (most recent call last):
  File "<function:runAction>", line 2, in runAction
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/ambient_api/ambientapi.py", line 4, in <module>
    import requests
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/ __init__.py", line 120, in <module>
    from . import utils
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/utils.py", line 27, in <module>
    from ._internal_utils import to_native_string
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/_internal_utils.py", line 11, in <module>
    from .compat import is_py2, builtin_str, str
  File "/usr/local/bin/ignition/user-lib/pylib/site-packages/requests/compat.py", line 31, in <module>
    import json
  File "/usr/local/bin/ignition/user-lib/pylib/json/ __init__.py", line 108, in <module>
    from .decoder import JSONDecoder
  File "/usr/local/bin/ignition/user-lib/pylib/json/decoder.py", line 24, in <module>
    NaN, PosInf, NegInf = _floatconstants()
  File "/usr/local/bin/ignition/user-lib/pylib/json/decoder.py", line 18, in _floatconstants
    _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
  File "user-lib/pylib/encodings/ __init__.py", line 142, in search_function
    raise CodecRegistryError,\
encodings.CodecRegistryError: incompatible codecs in module "encodings.hex_codec" (/usr/local/bin/ignition/user-lib/pylib/encodings/hex_codec.py)

Ignition v8.1.0 (b2020110211)
Java: Azul Systems, Inc. 11.0.7

```

I don’t understand what this is telling me. Can anyone help me through it?

---

<div class="post-metadata">

**Author:** ![alan.s.kinnaman](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@alan.s.kinnaman](https://forum.inductiveautomation.com/u/alan.s.kinnaman)\
**Post date:** [January 8, 2021, 3:29pm UTC](https://forum.inductiveautomation.com/t/encodings-codecregistryerror-attempt-to-get-data-from-weather-station-via-api/40546/2 "2021-01-08T15:29:31Z")

</div>

I see this problem occasionally, too. One thing that sometimes solves the problem sometimes is opening the project properties, making a minor change, and then saving the changes. It seems that this somehow triggers something to be refreshed.

There’s a discussion about this problem here:

[http://forum.inductiveautomation.com/t/codecregistryerror-when-importing-json-library/](http://forum.inductiveautomation.com/t/codecregistryerror-when-importing-json-library/)

I’ve also talked with Inductive Automation support about the issue, but we haven’t had any luck getting to the bottom of it.
