Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    cannot import name 'SmartConnect' from partially initialized module 'smartapi'

    Python SDK
    0
    5
    63
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Manish Ashar last edited by

      I am new to Python and started using your api in python. Using following code by going through few videos on youtube and your codes.

      from smartapi import SmartConnect #or from smartapi.smartConnect import SmartConnect
      #import smartapi.smartExceptions(for smartExceptions)

      is generating error

      PS C:\Users\DELL> & C:/Users/DELL/AppData/Local/Programs/Python/Python311/python.exe d:/Manish/Python/smartapi.py
      Traceback (most recent call last):
      File "d:\Manish\Python\smartapi.py", line 1, in <module>
      from smartapi import SmartConnect #or from smartapi.smartConnect import SmartConnect
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      from smartapi import SmartConnect #or from smartapi.smartConnect import SmartConnect
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      ImportError: cannot import name 'SmartConnect' from partially initialized module 'smartapi' (most likely due to a circular import) (d:\Manish\Python\smartapi.py)
      PS C:\Users\DELL> & C:/Users/DELL/AppData/Local/Programs/Python/Python311/python.exe d:/Manish/Python/smartapi.py
      Traceback (most recent call last):
      File "d:\Manish\Python\smartapi.py", line 5, in <module>
      obj=SmartConnect(api_key="ig3amEvr")
      ^^^^^^^^^^^^
      NameError: name 'SmartConnect' is not defined
      PS C:\Users\DELL> & C:/Users/DELL/AppData/Local/Programs/Python/Python311/python.exe d:/Manish/Python/smartapi.py
      Traceback (most recent call last):
      File "d:\Manish\Python\smartapi.py", line 1, in <module>
      from smartapi import SmartConnect #or from smartapi.smartConnect import SmartConnect
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "d:\Manish\Python\smartapi.py", line 1, in <module>
      from smartapi import SmartConnect #or from smartapi.smartConnect import SmartConnect
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      ImportError: cannot import name 'SmartConnect' from partially initialized module 'smartapi' (most likely due to a circular import) (d:\Manish\Python\smartapi.py)

      Please help.
      My contact details are manishashar888@gmail.com / 9173605833

      M F 2 Replies Last reply Reply Quote 1
      • M
        Manish Ashar @Manish Ashar last edited by

        @Manish-Ashar surprised that no body has time to reply or help me.

        M J 2 Replies Last reply Reply Quote 1
        • M
          Manish Ashar @Manish Ashar last edited by

          @Manish-Ashar Is it related to version of python?

          1 Reply Last reply Reply Quote 0
          • F
            falconTrader @Manish Ashar last edited by

            @Manish-Ashar
            Can you try by renaming your python file to something as "mySmartapi.py".
            It should not be the same name as that from the repository!

            1 Reply Last reply Reply Quote 0
            • J
              Javajp @Manish Ashar last edited by

              @Manish-Ashar i think u need to install packages 'smartapi-python' and
              'websocket-client'

              pip install smartapi-python
              pip install websocket-client

              1 Reply Last reply Reply Quote 0
              • First post
                Last post