How do I set up the Python access? I have a Refinitiv Workspace, is there a page describing the configuration necessary?
I think it requires anyio version 3.x or 4.x.
I am using anyio 3.3.4.
Hello @claudiu.schiller
Thank you for reaching out to us. I strongly suggest you check following the Data Library for Python resources as follows:
The examples can be downloaded from the GitHub repository.
If you encounter any issues, you can follow the steps on this Eikon Data API and Refinitiv Data Library - Troubleshooting article.
Thanks. I see 2 alternative packages documented: eikon and refinitiv-data. Are there advantages/disadvantages of working with either?
Follow-on question, maybe you can point to the source of the error I receive after trying to set the app key:
ek.set_app_key(XXXX)
[MainThread 16232] Error: no proxy address identified.[MainThread 16232] Error on handshake url http://127.0.0.1:None/api/handshake : InvalidURL("Invalid port: 'None'")
Regards,
Claudiu
The Eikon Data API is a feature-completed API, the Data Library for Python is the strategic API currently. The new API features will be added to the Data Library only. You can find more detail about Pros and Cons from this Upgrade from using Eikon Data API to the Data library article.
About the issue that you are facing. The Eikon Data API (or Data Library - Desktop session) needs to connect to the Workspace/Eikon desktop application in the same machine (localhost/127.0.0.1 ports 9060 and 9000) as a proxy between the API and the platform. Did you run the Workspace/Eikon desktop application in the same machine as the Python script?
Please try the steps on the following resources:
Thanks for the pointer. I did check the workspace is running and followed the troubleshooting article to show the DATA API PROXY is Ready. The older posts seem to indicate a library version incompatibility which I'm not sure is still relevant. Any pointers? Let me know if a new post would be better that continuing in this thread.
I did a quick test. The Eikon Data API version 1.1.18 works fine with httpx version 0.27.0 on my end.
Based on this What version of Eikon (Core, Research and Advisory, Premium) do you need to use the Python Data APIs? old post, the Eikon Data API (and Data Library - Desktop session) supports the Workspace/Eikon premium user only. Please confirm if your Workspace is premium account (you can contact your LSEG representative for more detail).
If you are already on the premium account, please follows the following instructions.
eikon: 1.1.18
httpx: 0.26.0
nest_asynco is not installed
See full log of failure below (replaced key id as XXX)
2024-03-11 09:58:21,239 P[888] [MainThread 21024] Reset a Desktop session with new app_key2024-03-11 09:58:21,246 P[888] [MainThread 21024] Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...2024-03-11 09:58:21,247 P[888] [MainThread 21024] Request to http://127.0.0.1:9000/api/status headers = {'x-tr-applicationid': 'XXXXXXXXXX'} params = None2024-03-11 09:58:21,249 P[888] [MainThread 21024] HTTP request failed: AttributeError("module 'anyio' has no attribute 'CancelScope'")2024-03-11 09:58:21,250 P[888] [MainThread 21024] Error on checking proxy url http://127.0.0.1:9000/api/status : AttributeError("module 'anyio' has no attribute 'CancelScope'")2024-03-11 09:58:21,254 P[888] [MainThread 21024] Retrieved port 9000 value from .portIntUse isn't valid.2024-03-11 09:58:21,255 P[888] [MainThread 21024] Warning: file .portInUse was not found. Try to fallback to default port number.2024-03-11 09:58:21,256 P[888] [MainThread 21024] Try defaulting to port 9000...2024-03-11 09:58:21,258 P[888] [MainThread 21024] Send GET request to http://127.0.0.1:9000/api/status to detect API Proxy...2024-03-11 09:58:21,259 P[888] [MainThread 21024] Request to http://127.0.0.1:9000/api/status headers = {'x-tr-applicationid': 'XXXXXXXXX'} params = None2024-03-11 09:58:21,261 P[888] [MainThread 21024] HTTP request failed: AttributeError("module 'anyio' has no attribute 'CancelScope'")2024-03-11 09:58:21,262 P[888] [MainThread 21024] Error on checking proxy url http://127.0.0.1:9000/api/status : AttributeError("module 'anyio' has no attribute 'CancelScope'")2024-03-11 09:58:21,263 P[888] [MainThread 21024] Default proxy port #9000 failed2024-03-11 09:58:21,264 P[888] [MainThread 21024] Try defaulting to port 9060...2024-03-11 09:58:21,265 P[888] [MainThread 21024] Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...2024-03-11 09:58:21,266 P[888] [MainThread 21024] Request to http://127.0.0.1:9060/api/status headers = {'x-tr-applicationid': 'XXXXXXXX'} params = None2024-03-11 09:58:21,267 P[888] [MainThread 21024] HTTP request failed: AttributeError("module 'anyio' has no attribute 'CancelScope'")2024-03-11 09:58:21,268 P[888] [MainThread 21024] Error on checking proxy url http://127.0.0.1:9060/api/status : AttributeError("module 'anyio' has no attribute 'CancelScope'")2024-03-11 09:58:21,269 P[888] [MainThread 21024] Default proxy port #9060 failed2024-03-11 09:58:21,270 P[888] [MainThread 21024] Error: no proxy address identified.Check if Eikon Desktop or Eikon API Proxy is running.2024-03-11 09:58:21,272 P[888] [MainThread 21024] Try to handshake on url http://127.0.0.1:None/api/handshake...2024-03-11 09:58:21,273 P[888] [MainThread 21024] Request to http://127.0.0.1:None/api/handshake headers = {'Content-Type': 'application/json', 'x-tr-applicationid': 'XXXXXXX'} params = None2024-03-11 09:58:21,274 P[888] [MainThread 21024] HTTP request failed: InvalidURL("Invalid port: 'None'")2024-03-11 09:58:21,275 P[888] [MainThread 21024] Error on handshake url http://127.0.0.1:None/api/handshake : InvalidURL("Invalid port: 'None'")2024-03-11 09:58:21,276 P[888] [MainThread 21024] Error on handshake url http://127.0.0.1:None/api/handshake : InvalidURL("Invalid port: 'None'")2024-03-11 09:58:21,277 P[888] [MainThread 21024] Port number was not identified, cannot send any request2024-03-11 09:58:21,278 P[888] [MainThread 21024] Received notification for closed streaming session 02024-03-11 09:58:21,278 P[888] [MainThread 21024] Received notification for closed streaming session 02024-03-11 09:58:21,279 P[888] [MainThread 21024] Init a Desktop session with new app_key
Please check the version of anyio used in the application.
anyio at 2.2.0
I can install newer and check tomorrow if this is the cause (installing new packages in our env is a bit complex)
I am using anyio version 3.4.0. Please try to upgrade the anyio as suggest by my colleague above.
pip install anyio --upgrade
or
pip install anyio==<version> --upgrade
You can check the versions of anyio from the PyPI history page.
Upgrading anyio to v3.4 helped. Now I get data. Thanks a lot for the help.
I am glad to hear that the issue is resolved on you end.
I strongly suggest you keep this environment setting for later use. You can use the pip freeze command to generate a requirements file and then install from it in another environment.
python -m pip freeze > requirements.txt
To install the same set of libraries versions:
python -m pip install -r requirements.txt