Error when I tried to import refinitiv.dataplatform

When I tried to run the following lines of codes in Python,

import refinitiv.dataplatform.eikon as ek
ek.set_app_key('#############################')

I bumpted into the followign error message. Can someone help me address the error?

Traceback (most recent call last):
File "C:\Users\********\AppData\Local\Temp\***********py", line 2, in <module>
ek.set_app_key('###########################)
File "C:\Users\********\Anaconda3\envs\*******\lib\site-packages\refinitiv\dataplatform\legacy\tools.py", line 210, in set_app_key
_session = get_default_session(app_key)
File "C:\Users\*******\Anaconda3\envs\*********\lib\site-packages\refinitiv\dataplatform\legacy\tools.py", line 200, in get_default_session
return DefaultSession.get_default_session(app_key)
File "C:\Users\******\Anaconda3\envs\***********\lib\site-packages\refinitiv\dataplatform\legacy\tools.py", line 240, in get_default_session
cls.__default_session = DesktopSession(app_key)
File "C:\Users\*********\Anaconda3\envs\**********\lib\site-packages\refinitiv\dataplatform\core\session\desktop_session.py", line 41, in __init__
super().__init__(
File "C:\Users\***********\Anaconda3\envs\**********\lib\site-packages\refinitiv\dataplatform\core\session\session.py", line 342, in __init__
self._http_session = httpx.AsyncClient(
File "C:\Users\**********\Anaconda3\envs\**********\lib\site-packages\httpx\_client.py", line 1394, in __init__
self._transport = self._init_transport(
File "C:\Users\**********\Anaconda3\envs\**********\lib\site-packages\httpx\_client.py", line 1442, in _init_transport
return AsyncHTTPTransport(
File "C:\Users\**********\Anaconda3\envs\**********\lib\site-packages\httpx\_transports\default.py", line 264, in __init__
self._pool = httpcore.AsyncConnectionPool(
File "C:\Users\**********\Anaconda3\envs\**********\lib\site-packages\httpcore\_async\connection_pool.py", line 107, in __init__
self._pool_lock = AsyncLock()
File "C:\Users\**********\Anaconda3\envs\**********\lib\site-packages\httpcore\_synchronization.py", line 12, in __init__
self._lock = anyio.Lock()
AttributeError: module 'anyio' has no attribute 'Lock'

Best Answer

  • Jirapongse
    Jirapongse admin
    Answer ✓

    @iwasaki

    It looks like that the version of anyio loaded by the application doesn't have the Lock attribute.

    You can run the following code to verify the problem.

    import anyio
    print(anyio.__file__)
    print(open(anyio.__file__).read())
    anyio.Lock()

    For more information, please refer to this discussion.

Answers

  • My anyio package is version 3.6.1.

    anyio 3.6.1 pypi_0 pypi

  • @Jirapongse

    Thank you for the lines of diagnostic codes. I see print(anyio.__file__) gives me None, and realize something is out of place. Although conda list in my terminal shows anyio package is installed, its path is not recognized. I uninstalled & installed the package again and it works fine now.