(Resolved) ModuleNotFoundError: No module named 'DhanSDK'

I’ve got this error while running Caller Function. What is needed to be done to mitigate this problem??

1 Like

Hello @k4u5h47

Welcome to Dhan Community!

You can use starter code from here: GitHub - dhan-oss/DhanHQ-py: The official Python client for communicating with the Dhan API. to get started with Websockets on Python library.

Hope this helps!

Hello @Hardik Every time I run websockets for real time live ltp, it got closed by saying this message:


Disconnected: Subscribe to Data APIs to continue. But as we know Dhan APis are free for it’s users.

Hey @Hardik
I am using this code:


After running this I think execution got stuck after this:
PS F:\New folder\websockets> python caller_function.py
Subscription code : 15
C:\Users\jai71\AppData\Local\Programs\Python\Python312\Lib\site-packages\dhanhq\marketfeed.py:79: RuntimeWarning: coroutine ‘DhanFeed.connect’ was never awaited
self.connect()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Connected to websocket
Connected to websocket

Please look into this issue.

Hello @Jai7

Welcome to Dhan Community!

Over here, if you look at the Disconnection message, it states that you haven’t subscribed to Data APIs yet to be eligible to use the same. Kindly go to web.dhan.co > DhanHQ Trading APIs to ensure you have subscribed to Data APIs.