Search code examples
pythonfunctionclassspyderprogram-entry-point

if __name__ == "__main__": failing; why won't __main__ call my classes?


I have been simplifying this code and I am without words. Simply put, the file will not run to call the classes present, and by extension the functions within. The error is something I have never come across and would like some clarity on, if someone could provide it, please.

class Server_Design:
    def __init__(self):
        self.intro_input()

    def intro_input(self):
        self.host = input('Host: ')
        self.port = input('Port: ')
        print("y")

if __name__ == "__main__":
    Server_Design()

COMMAND LINE OUTPUT:

    [SpyderKernelApp] ERROR | Exception in message handler:
    Traceback (most recent call last):
      File "C:\Users\ ----\anaconda3\lib\site-packages\spyder_kernels\comms\frontendcomm.py", line 164, in poll_one
        asyncio.run(handler(out_stream, ident, msg))
      File "C:\Users\ ----\anaconda3\lib\site-packages\nest_asyncio.py", line 33, in run
        task = asyncio.ensure_future(main)
      File "C:\Users\ ----\anaconda3\lib\asyncio\tasks.py", line 677, in ensure_future
        raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
    TypeError: An asyncio.Future, a coroutine or an awaitable is required
    [SpyderKernelApp] ERROR | Exception in message handler:
    Traceback (most recent call last):

repeating indefinitely


Solution

  • This error was fixed in Spyder 5.2.0 (released on November 2021). Please update to a more recent version by following the instructions posted here.