question

Upvotes
Accepted
0 0 0 1

refinitiv.data module (python)

Hi,

I am trying to use refinitiv.data module.

I follow the steps of this page : https://github.com/Refinitiv-API-Samples/Example.DataLibrary.Python/blob/main/Examples/2-Content/2.02-Pricing/EX-2.02.03-Pricing-StreamingCache.ipynb

Here is the error I receive when running tgis code :

import os

os.environ["RD_LIB_CONFIG_PATH"] = "./"

import refinitiv.data as rd

from refinitiv.data.content import pricing

from pandas import DataFrame

rd.open_session("platform.rdp")


>>

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/config/configuration.py", line 155, in __getitem__

raise KeyError(item)

KeyError: 'config-change-notifications-enabled'


What is wrong here ?

Many thanks

python apiconfiguration
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvote
Accepted
53k 137 44 63

@CyrilC

I assume that you modified the default configuration file (refinitiv-data.config.json) in the RD library package at Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/refinitiv/data/refinitiv-data.config.json. This file should contain the "config-change-notifications-enabled" setting.

1660871524627.png

If I remove this setting from this default configuration file, I will get the same error.

c:\python37\lib\site-packages\config\configuration_set.py in _from_configs(self, attr, *args, **kwargs)
     59         for config_ in self._configs:
     60             try:
---> 61                 values.append(getattr(config_, attr)(*args, **kwargs))
     62             except Exception as err:
     63                 last_err = err

c:\python37\lib\site-packages\config\configuration.py in __getitem__(self, item)
    153 
    154         if v == {}:
--> 155             raise KeyError(item)
    156         if isinstance(v, dict):
    157             return Configuration(v)

KeyError: 'config-change-notifications-enabled'

In summary, there are two refinitiv-data.config.json files. The default one is in the package directory which contains the default settings, such as "config-change-notifications-enabled". Another one is in the application directory which contains session settings, such as "platform.rdp". You should not modify the default one in the package directory.



1660871524627.png (44.8 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you so much Jirapongse.


It sorted it out and makes the code run !


Upvotes
0 0 0 1

Just let me add that I use python version 3.9.

The code has been ran with IDLE.

I may add some more lines in the error report :

File "/Users/Documents/PYTHON/test.py", line 22, in <module>

rd.open_session("platform.rdp")

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/refinitiv/data/_fin_coder_layer/session.py", line 44, in open_session

_config_object = get_config()

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/refinitiv/data/_config_functions.py", line 14, in get_config

return _get_config()

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/refinitiv/data/_configure.py", line 372, in get_config

reload()

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/refinitiv/data/_configure.py", line 431, in reload

_watch_enabled = _config.get_bool(keys.watch_enabled)

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/config/configuration.py", line 200, in get_bool

return as_bool(self[item])

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/config/configuration_set.py", line 110, in __getitem__

return self._from_configs("__getitem__", item)

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/config/configuration_set.py", line 67, in _from_configs

raise last_err

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/config/configuration_set.py", line 61, in _from_configs

values.append(getattr(config_, attr)(*args, **kwargs))

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/config/configuration.py", line 155, in __getitem__

raise KeyError(item)

KeyError: 'config-change-notifications-enabled'

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
16.7k 42 12 19

Hello @CyrilC,

Can you please ensure/confirm that you have followed the Quick Start guide and all the installation steps defined in it.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
0 0 0 1

Yes I did.

> pip install refinitiv.data

I modified the refinitiv-data.config.json file according to a developer instructions (so it has been tested on his computer)

And it seems the issue comes from the configuration file is not read.

As written on github, and written above, I added the Config environment path to tell where my new config file is located (next to my python script):

os.environ["RD_LIB_CONFIG_PATH"] = "./"

None worked

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
16.7k 42 12 19

It looks like there might be an error in your configuration file. Can you download the sample configuration file from here. If you are using RDP then fill in the appkey, username and password section and try again.

This sessions jupyter notebook is also helpful in testing out the credentials and configuration issues. You can hardcode the appkey/username/password in the cell and see if the session creation works for you. Cell# 17 creates an RDP session.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
13.1k 61 39 63

Hi @CyrilC

Can you try the following:

  • Ensure you have your config file (refinitiv-data.config.json) in your current working directory - same directory where you are running your code
  • The config file should look like this (with the proper credentials defined)
  • ahs.png
  • Create a small example with the following Python code
  • ahs.png

If there is success, you will see output similar to the above screenshot. Note: because I placed the config file within the current working directory, there is no need to explicitly define the environment variable - the library will automatically find the config file.


ahs.png (16.2 KiB)
ahs.png (6.9 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi,

I tried that at the beginning. It did not work.

Then, I have been told to set the os.Environ path (which I did as you can read above). It did not work either.

I just received an email explaining it is a well known issue with IDLE that seems to hide a lib dependency (configuration). See jira / browse / EAPI-4369

So, quite obvious it can't work without a possibility to configure.

Yet, this does not sort out the issue : how can I force IDLE (or anything) to import the library ?