Eikon API - AsynclibraryNotFoundError

eikon-api-error.png

when we use Eikon API, it shows the error message. Please tell us the cause of this error, thanks.

Best Answer

  • pf
    pf
    Answer ✓

    Hi @xuke ,

    Thank you for reaching out to us.

    I don't reproduced your issue but found where this exception is raised in httpx dependency.

    We need more information on your script and how eikon lib is used so could you share your code (without any personal id, login or password) ?

    Could you also provide which Python version you're using and check eikon + httpx versions with this code?

    import eikon
    import httpx
    print(httpx.__version__)
    print(eikon.__version__)

    On your side, you can test following code to check if it's failing too (it should run without error):

    import asyncio
    from sniffio import current_async_library

    async def print_lib():
    library = current_async_library()
    print("This is the current async lib: ", library)

    asyncio.run(print_lib())


Answers

  • 1705643354693.png

    1705643383733.png

    def get_stock_commodity_code(request):
    success = True
        val = json.loads(request.body)
    code = val.get("code")
    date = val.get("date")
    return_dict = {'return_code': '200', 'return_info': 'success', 'result': False}
        set_rv_app_key()
     try:
            rd.open_session()
            df = rd.discovery.search(
     view=rd.discovery.Views.SEARCH_ALL,
    top=1,
    # filter="LocalFundCode in ('006038' '012728')",
                    filter="TickerSymbol eq '" + code + "' and ExpiryDateString eq '" + date + "' and DerivedCategory eq 'Future'",
    select="DocumentTitle,RIC"
            )

    except Exception as result:
    errorMsg = str(result)
    loggers.error("get commodity info exception: " + str(result))
    success = False
        if success:
    df.columns = ['instrument', 'ricCode']
            result_data = df.to_json()
    loggers.info("get commodity info response: " + result_data)
    # data.to_excel("C:\\dpp\\refinitive\\test\\stock.xlsx", sheet_name='Sheet1', index=False)
            return_dict['result'] = json.loads(result_data)
     else:
    return_dict['return_code'] = 500
            return_dict['return_info'] = errorMsg
    return_dict['result'] = {}
    return HttpResponse(json.dumps(return_dict), content_type="application/json")
  • First of all, I didn't see that an error is logged before the AsynciolibraryNotFoundError !
    In previous lines, you should have some information similar to :

    [2024-01-18 18:16:25,071;s] - [INFO] - [log] - Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...
    [2024-01-18 18:16:25,071;s] - [DEBUG] - [log] - Request to http://127.0.0.1:9060/api/status
    ....

    Could you share it ? (take care to remove your app key).
    Note that you'll find tips and tricks to check your environment (especially if Eikon API proxy is available) in Troubleshooting Userguide.


    About your code, I reformat it:

    def get_stock_commodity_code(request):
    success = True
    val = json.loads(request.body)
    code = val.get("code")
    date = val.get("date")
    return_dict = {"return_code": "200", "return_info": "success", "result": False}
    set_rv_app_key()
    try:
    rd.open_session()
    df = rd.discovery.search(
    view=rd.discovery.Views.SEARCH_ALL,
    top=1,
    # filter="LocalFundCode in ('006038' '012728')",
    filter="TickerSymbol eq '"
    + code
    + "' and ExpiryDateString eq '"
    + date
    + "' and DerivedCategory eq 'Future'",
    select="DocumentTitle,RIC",
    )
    except Exception as result:
    errorMsg = str(result)
    loggers.error("get commodity info exception: " + str(result))
    success = False
    if success:
    df.columns = ["instrument", "ricCode"]
    result_data = df.to_json()
    loggers.info("get commodity info response: " + result_data)
    # data.to_excel("C:\\dpp\\refinitive\\test\\stock.xlsx", sheet_name='Sheet1', index=False)
    return_dict["result"] = json.loads(result_data)
    else:
    return_dict["return_code"] = 500
    return_dict["return_info"] = errorMsg
    return_dict["result"] = {}
    return HttpResponse(json.dumps(return_dict), content_type="application/json

    My feedbacks:

    1. you should manage the rd.open_session() on initializing your application, and close it (rd.close_session()) on closing your application.
    2. set_rv_app_key() is called before rd.open_session() but according to your initial log, it's the inverse:
      1705652863553.pngIs this correct or are the logs out of order?
    3. The context of calling get_stock_commodity_code() could cause the error.
      Is there any specific multi-threaded or multi-processed design?


  • @pf

    1705886841648.png

    we will accept your suggestion to try again

  • @pf

    1705973478094.png

    1. you should manage the rd.open_session() on initializing your application, and close it (rd.close_session()) on closing your application.

    Is this question related to this advise?


  • 1705656738511.png

    we will try to run program with this advises

    1. you should manage the rd.open_session() on initializing your application, and close it (rd.close_session()) on closing your application.
    2. set_rv_app_key() is called before rd.open_session() but according to your initial log, it's the inverse:
      imageIs this correct or are the logs out of order?
  • 1705656983849.png


    we will try to run program with this advises


    1. you should manage the rd.open_session() on initializing your application, and close it (rd.close_session()) on closing your application.

    set_rv_app_key() is called before rd.open_session() but according to your initial log, it's the inverse:imageIs this correct or are the logs out of order?
  • Hi,

    I noticed that during initialization, the initial steps are failing.

    Could you verify that your Eikon product is allowed for Python usage. In Help>About Refinitiv Eikon, APPS tab, you should find REFINITIVHOLDINGS.EIKON.DATAAPIPROXY app:

    1705996038016.png

    Then test http://localhost:9060/api/status to verify if the Data API Proxy was started successfully:

    1705996136533.png


  • 1705996674819.png

    1705996699180.png

    this is right

  • Your versions arn't recent:

    • Eikon 3.3.11
    • DATA API PROXY 1.9.0.0

    It could explain why it's failing.
    Did it work before ?

    You should contact your Account Manager to upgrade to Eikon 3.6.6 (it contains API Proxy 1.10.0.0).


  • @pf Thanks for your advice. We connect the support hotline, but failed to upgrade from Eikon 3.3.11 (Data API Proxy 1.9.0.0) to Eikon 3.6.6 (Data API Proxy 1.10.0.0).
    Below information for your reference.


    Steps Done:
    Eikon had been uninstalled and reinstalled by PC Admin.

    1. Ended Excel, Word, PPT and Eikon processes.
    2. Uninstalled the obsolete version of Eikon from Windows Control Panel > Programs and Features.
    3. Downloaded the latest version Eikon 4.0.64, installed Eikon 4.0.64 and VBA71 one by one with PC Admin.
    4. Logged in Eikon 4.0.64 successfully.

    Checked the Data API Proxy version: it was showing Eikon 3.3.11 (Data API Proxy 1.9.0.0), failed to upgrade.

    5. Referred to below link, tried the steps, the version still at Eikon 3.3.11 (Data API Proxy 1.9.0.0).

    https://developers.lseg.com/en/api-catalog/eikon/eikon-data-api/tutorials#how-to-update-your-eikon-data-api

  • Hi @xuke ,

    Have you tried restart the machine and check the data API proxy version again? Some process of the proxy might not ended properly previously.

  • Hi Raksina,

    Yes, already restart the machine. but the data API proxy version is still

    {"statusCode":"ST_PROXY_READY","version":"3.3.11-eikon4"}
  • Hi @xuke ,

    Thank you for your patience, could you please let me know if you're able to run the code properly?

    And I'd like to confirm which Python library are you using? as in your code, seem like the 'rd' is being used.

    Are you using the Refinitiv Data Library for Python

    import refinitiv.data as rd

    or Eikon Data API

    import eikon as ek

    If it's the first one, could you please let me know which version of the data library you're using with the code below?

    print(rd.__version__)