Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1

    Lightstreamer in Anaconda Python Distribution

    Hello all,

    I've been just starting to try to use the Lightstreamer client in Python 3.9 in the Spyder IDE, and I get an error on import.

    The only line of code I run is:
    Code:
    from lightstreamer_client import *
    and I get the following output:
    Code:
    Traceback (most recent call last):
    
      Cell In[1], line 1
        from lightstreamer_client import *
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\__init__.py:1
        from .com_lightstreamer_client import *
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:16034
        com_lightstreamer_internal_EventDispatcher.executor = com_lightstreamer_internal_EventDispatcher.createExecutor()
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:2318 in createExecutor
        return hx_concurrent_executor_Executor.create(1)
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1902 in create
        return hx_concurrent_executor_ThreadPoolExecutor(maxConcurrent,autostart)
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1978 in __init__
        super().__init__()
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1887 in __init__
        super().__init__()
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1781 in __init__
        haxe_Log.trace((("[" + Std.string(self)) + "] instantiated."),_hx_AnonObject({'fileName': "hx/concurrent/Service.hx", 'lineNumber': 56, 'className': "hx.concurrent.ServiceBase", 'methodName': "new"}))
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:2316 in _hx_local_0
        python_Lib.printString((("" + Std.string(haxe_Log.formatOutput(v,infos))) + HxOverrides.stringOrNull(python_Lib.lineEnd)))
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1687 in printString
        python_lib_Sys.stdout.buffer.write(_hx_str.encode("utf-8", "strict"))
    
    
    AttributeError: 'TTYOutStream' object has no attribute 'buffer'
    
    
    
    
    from lightstreamer import *
    
    
    import lightstreamer_client
    Traceback (most recent call last):
    
    
      Cell In[3], line 1
        import lightstreamer_client
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\__init__.py:1
        from .com_lightstreamer_client import *
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:16034
        com_lightstreamer_internal_EventDispatcher.executor = com_lightstreamer_internal_EventDispatcher.createExecutor()
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:2318 in createExecutor
        return hx_concurrent_executor_Executor.create(1)
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1902 in create
        return hx_concurrent_executor_ThreadPoolExecutor(maxConcurrent,autostart)
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1978 in __init__
        super().__init__()
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1887 in __init__
        super().__init__()
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1781 in __init__
        haxe_Log.trace((("[" + Std.string(self)) + "] instantiated."),_hx_AnonObject({'fileName': "hx/concurrent/Service.hx", 'lineNumber': 56, 'className': "hx.concurrent.ServiceBase", 'methodName': "new"}))
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:2316 in _hx_local_0
        python_Lib.printString((("" + Std.string(haxe_Log.formatOutput(v,infos))) + HxOverrides.stringOrNull(python_Lib.lineEnd)))
    
    
      File ~\anaconda3\envs\Economic\lib\site-packages\lightstreamer_client\com_lightstreamer_client.py:1687 in printString
        python_lib_Sys.stdout.buffer.write(_hx_str.encode("utf-8", "strict"))
    
    
    AttributeError: 'TTYOutStream' object has no attribute 'buffer'

  2. #2
    Hello,


    Unfortunately, we have no experience with Anaconda and Spyder IDE.
    Can you suggest what tools we need to install to reproduce your environment?

  3. #3
    Hello and thanks,

    Anaconda distribution with Spyder and Command prompt installed.
    Perform a regular pip install of the lightstreamer library through the command prompt in Anaconda.
    In Spyder, enter "from lightstreamer_client import *" (depending on version you may need to say lightstreamer.client or lightstreamer_client)
    you will reproduce the error above.

    Thanks!

  4. #4
    The error is from a third-party library used by the Lightstreamer Python Client, which tries to print some logs to the virtual console of the Spyder IDE. It seems that this console has some limitations with respect to the standard console. Indeed if you run the same code from the Anaconda Prompt, the Client works as expected.


    If possible, I’ll try to fix this issue in a next release of the SDK, but in the meantime my advice is to write your program with Spyder but to run it only from the Anaconda Prompt.

  5. #5
    Thanks for the update, but it doesn't work from the command line, in Jupyter Notebook, or in Spyder. Would I find out about the new version from github?
    Thanks!

  6. #6
    Have you tried to run your script from the Anaconda Prompt?

    To open Anaconda Prompt:

    - Windows: Click Start, search for Anaconda Prompt, and click to open.
    - macOS: Use Cmd+Space to open Spotlight Search and type “Navigator” to open the program.
    - Linux: Open Applications > System Tools > terminal.

    You can find further details here.

    Anyway I’m working on the new version of the Client lib, which I hope could resolve the issue.

  7. #7
    I've just released the Python Client SDK 1.0.2 which should fix the issue with Anaconda.
    Check it out when you can.

  8. #8
    Thanks, I did a reinstall and got this:

    Traceback (most recent call last):


    File ~\anaconda3\envs\light_streamer\lib\site-packages\aiohttp\client_reqrep.py:70
    import cchardet as chardet


    ModuleNotFoundError: No module named 'cchardet'




    During handling of the above exception, another exception occurred:


    Traceback (most recent call last):


    Cell In[2], line 1
    from lightstreamer.client import *


    File ~\anaconda3\envs\light_streamer\lib\site-packages\lightstreamer\client\__init__.py:2
    from .ls_python_client_wrapper import *


    File ~\anaconda3\envs\light_streamer\lib\site-packages\lightstreamer\client\ls_python_client_wra pper.py:2
    from .ls_python_client_haxe import LSConsoleLoggerProvider, LSConsoleLogLevel, LSProxy, LSSubscription, LSConnectionDetails, LSConnectionOptions, LSLightstreamerClient


    File ~\anaconda3\envs\light_streamer\lib\site-packages\lightstreamer\client\ls_python_client_hax e.py:10
    from .com_lightstreamer_net import CookieHelper as com_lightstreamer_internal_CookieHelper


    File ~\anaconda3\envs\light_streamer\lib\site-packages\lightstreamer\client\com_lightstreamer_ne t.py:1
    import aiohttp


    File ~\anaconda3\envs\light_streamer\lib\site-packages\aiohttp\__init__.py:6
    from .client import (


    File ~\anaconda3\envs\light_streamer\lib\site-packages\aiohttp\client.py:59
    from .client_reqrep import (


    File ~\anaconda3\envs\light_streamer\lib\site-packages\aiohttp\client_reqrep.py:72
    import charset_normalizer as chardet # type: ignore[no-redef]


    File ~\anaconda3\envs\light_streamer\lib\site-packages\charset_normalizer\__init__.py:23
    from charset_normalizer.api import from_fp, from_path, from_bytes, normalize


    File ~\anaconda3\envs\light_streamer\lib\site-packages\charset_normalizer\api.py:10
    from charset_normalizer.md import mess_ratio


    File charset_normalizer\md.py:5
    from charset_normalizer.utils import is_punctuation, is_symbol, unicode_range, is_accentuated, is_latin, \


    ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (C:\Users\frank\anaconda3\envs\light_streamer\lib\ site-packages\charset_normalizer\constant.py)

  9. #9
    It seems a problem related to aiohttp, a library used by the Lightstreamer Client to make http and websocket connections.
    I really don’t know why it happens but you can try the workaround suggested in this SO post.

  10. #10
    OK, I asked chatGPT and it told me to:
    pip install cchardet
    - it worked!


 

 

Similar Threads

  1. Python client for lightstreamer
    By Colombao in forum Client SDKs
    Replies: 79
    Last Post: July 7th, 2020, 10:05 AM
  2. php/perl/python lightstream client
    By Eli Shabtay in forum Client SDKs
    Replies: 1
    Last Post: May 11th, 2015, 09:48 AM
  3. php/perl/python lightstream client
    By Eli Shabtay in forum General
    Replies: 1
    Last Post: May 11th, 2015, 09:48 AM
  4. Python Client Library for Lightstreamer
    By Alessandro in forum Client SDKs
    Replies: 1
    Last Post: December 18th, 2014, 06:15 PM
  5. how to comunicate lightstreamer server by python
    By keyan in forum Client SDKs
    Replies: 4
    Last Post: December 18th, 2014, 06:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 01:01 PM.