I have an issue with lseg library on python (API), The session is opened correctly but I get an importError ( Image attached). Have you met this issue before?
Current lseg version : lseg_analytics-2.1.0b1 lseg_data-2.1.1.
@jordan_chu
I could replicate the same error.
You can try this code:
from lseg.data.delivery._stream import *
>>> from lseg.data.delivery._stream import * Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\_tools\_lazy_loader.py", line 80, in __getattr__ submod = importlib.import_module(submod_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python312\Lib\importlib\__init__.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1387, in _gcd_import File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 995, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\delivery\_stream\omm_stream.py", line 5, in <module> from ._stream_factory import get_service_and_details_omm File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\delivery\_stream\_stream_factory.py", line 6, in <module> from ._off_stream_contrib_connection import OffStreamContribConnection File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\delivery\_stream\_off_stream_contrib_connection.py", line 1, in <module> from .omm_stream_connection import OMMStreamConnection File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\delivery\_stream\omm_stream_connection.py", line 4, in <module> from .stream_connection import StreamConnection, LOGIN_STREAM_ID File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\delivery\_stream\stream_connection.py", line 15, in <module> from .ws.ws_client import WebSocketClient File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\delivery\_stream\ws\ws_client.py", line 8, in <module> class WebSocketClient: File "C:\Users\jphuriph\venv1\venv\Lib\site-packages\lseg\data\delivery\_stream\ws\ws_client.py", line 17, in WebSocketClient def _on_ws_message(self, ws: websocket.WebSocketApp, s: str) -> None: ^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'websocket' has no attribute 'WebSocketApp'. Did you mean: 'web_socket_app'?
It turns out that my current directory has the websocket.py file that conflicts with the websocket library usd by the lseg.data library.
(venv) C:\Users\jphuriph\venv1\venv>dir Volume in drive C has no label. Volume Serial Number is 5AE4-C28C Directory of C:\Users\jphuriph\venv1\venv 04/17/2026 02:32 PM <DIR> . 04/17/2026 12:54 PM <DIR> .. 04/17/2026 12:54 PM <DIR> Include 04/17/2026 12:54 PM <DIR> Lib 04/17/2026 12:54 PM 229 pyvenv.cfg 04/17/2026 02:30 PM <DIR> Scripts 04/17/2026 01:11 PM 103 test.py04/17/2026 09:30 AM 6,183 websocket.py 04/17/2026 02:23 PM <DIR> __pycache__ 3 File(s) 6,515 bytes 6 Dir(s) 207,733,231,616 bytes free (venv) C:\Users\jphuriph\venv1\venv>
I suspect that the current directory contains other Python files that may conflict with the libraries required by the ld.data module. Please create a new, empty folder and run the Python script from that directory.
Hello @Shaina.Labro
Could you please share the following information?
pip show lseg-data
Does the Python environment share with other projects? You might need to create a clean, new Python Virtual (or Conda) environment and flash install the lseg-data and other requires library for the project. You can see a step-by-step guide on https://developers.lseg.com/en/article-catalog/article/step-by-step-guide-install-data-library-python-virtual-env article.
I have tried the lseg-analytics version 2.1.0b1 and https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python version 2.1.1 on my local machine (Desktop session). The code works fine on my end (Python 3.12.4).
I have tried to replicate the issue by installing the libraries with the following command:
pip install lseg-analytics==2.1.0b1 lseg-data
The Data Library code works fine on my end (Desktop Session).
import lseg.data as ld if __name__ == "__main__": ld.open_session() quote = ld.get_data(universe=["EUR="], fields=["BID","ASK"]) print(quote)
Additionally, the lseg-analytics library has been deprecated and is no longer maintained. The Analytics Team suggests you uninstall the lseg-analytics package in use the https://pypi.org/project/lseg-analytics-pricing/ instead. However, this might not be related to the original issue.
Hi @wasin.w V3 Thank you so for your answer. I've asked the client for the asked information. Please see below details:
Python version : 3.13.7.
Snippet code :
import lseg.data as ld
if __name__ == "__main__":
session=ld.open_session()
print(session)
quote = ld.get_data(universe=["EUR="], fields=["BID","ASK"])
print(quote)
DesktopSession :
name = workspace
connection = DesktopConnection
stream_auto_reconnection = True
handshake_url = http://localhost:9001/api/handshake
state = OpenState.Opened
session_id = 0
logger_name = sessions.desktop.workspace.0
pip show lseg-data :
Name: lseg-data
Version: 2.1.1
Summary: Client for LSEG Data Platform API's
Home-page: https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python
Author: LSEG
Author-email:
License: Apache 2.0
Location: c:\Program Files\Python313\Lib\site-packages
Requires: appdirs, httpcore, httpx, jinja2, numpy, pandas, pyee, pyhumps, python-dateutil, requests, scipy, simplejson, tenacity, watchdog, websocket-client
Required-by:
Note: you may need to restart the kernel to use updated packages.
Installed version:
Numpy : 2.3.5
Httpcore : 1.0.9
Httpx:0.27.2
Jinja2 : 3.1.6
Pandas : 2.3.0
Pyee : 12.0.0
Pyhumps: 3.8.0
Requests :2.32.5
Scipy : 1.17.0
Tenacity : 9.1.2
Watchdog : 6.0.0
Websocket_client : 1.9.0
@Shaina.Labro
Can you run the following commands to verify the objects in the lseg.data.delivery._stream module?
import lseg.data.delivery._stream as st dir(st)
Hi @Jirapongse, I'll ask the suer to run this on their end.
Hi @Jirapongse, here's the response. The function does appear when I run this:
That is strange. It looks like that the get_service_and_details_omm object is available in that module.
The client can try with this code.
import importlib importlib.import_module('lseg.data._access_layer.get_data_func')
Please make sure the client runs the code in the same environment where the error occurs.
Hi, I am the one who requested help on this matter, Shaina gave me access to this chat directly.
the function seems to be available, but can't get imported :
Thanks
Hi, I was the one requesting for help on this matter,
The function seems available, but the error occurs when it is imported :
Hi, I am the client, Shaina gave me access to this post directly:
I ran the code, but the function can't be imported correctly
I can't replicate this issue.
Can you try to uninstall and reinstall the lseg-data package?
I would like to scope down the issue.
Please try this code.
import lseg.data._tools._lazy_loader as lzl import importlib attach_org = lzl.attach def attach_new(package_name, submodules=None, submod_attrs=None): print(f"### attach_new: {package_name}, {submodules}, {submod_attrs} ###") return attach_org(package_name, submodules, submod_attrs) lzl.attach = attach_new mod = importlib.import_module('lseg.data.delivery._stream') dir(mod)
Hi, this is the result:
['AckContribResponse', 'BaseStream', 'ContribResponse', 'ContribType', 'ErrorContribResponse', 'NullContribResponse', 'OMMStream', 'OMMStreamConnection', 'OffStreamContribConnection', 'OptContribT', 'PrvOMMStream', 'PrvRDPStream', 'RDPStream', 'RDPStreamConnection', 'RejectedContribResponse', 'StreamCache', 'StreamConnection', 'StreamEvt', 'StreamOpenMixin', 'StreamOpenWithUpdatesMixin', 'StreamStEvt', 'contribute', 'contribute_async', 'get_cxn_cfg_provider', 'get_cxn_config', 'get_service_and_details_omm', 'get_service_and_details_rdp', 'stream_cxn_cache']
Does it work if you run this code before running the actual code?
import importlib importlib.import_module('lseg.data.delivery._stream') import lseg.data as ld ld.open_session() quote = ld.get_data(universe=["EUR="], fields=["BID","ASK"])
I have contacted the product team to verify this issue.
No, I get the same error :
Hello @jordan_chu
I see you have installed the library and run from your global Python installation (c:\program files\python313\ folder). May I ask you to create a Python Virtual Environment, clear a pip tool cache, re-install the Data Library and try some code to see if the problem still persists?
This test case is for verifying if any other Python libraries in your global site-package cause the conflict with the Data Library.
A Python virtual environment is an isolated, separate, python workspace for your project. It contains own Python interpreter, installed libraries, and dependency versions. It allows you to manage dependencies for different projects independently, preventing version conflicts.
Step 1: Clear pip tool's cache for a clean, flash download library packages.
python -m pip cache purge
Step 2: Create a Python virtual environment name venv using the Python venv tool.
python -m venv venv venv
Step 3: Activate a Python venv environment
c:\folder>venv\Script\activate (venv) c:\folder>
Please be noticed the prefix (venv) after activated.
Step 5: Install the Data Library
(venv) c:\folder>pip install lseg-data
Step 6: Once the library installation is succeeded, try the following code on the Python interactive shell while you are in the venv environment.
Hi,
Unfortunately, the IT prevents us from installing external libraries by ourselves, so I can create a venv but can't install anything on it. I'll ask them to reinstall the library.
Thank you.
Yes, I get the same error message, it does seem to be the answer.
Thanks for your time.