AttributeError: 'super' object has no attribute 'init

when I try to run my code in the Visual Studio Code I get, AttributeError: ‘super’ object has no attribute ‘init’

traditionally the function is named __init__ (with double underscores on both sides). This might be the issue, but if the superclass actually does have a function called init then it could be something else.

You need to call super(), not just reference the name.

@Akuhr70 Please do not post pictures-of-code when asking for assistance. Pictures of code are not accessible to many people relying on assistive technologies, and make it more difficult for people to help, since the text cannot be copy-and-pasted if needed. Instead, always post code-like text as actual text, in formatted code blocks.


I’ve filed an issue with the pyttx3 project about this.

The problem is that PyObjC, which is used by pyttx3 on macOS, requires using its implementation of super instead of the builtin one due to the way method resolving is done. PyObjC has some more documentation about this.

As a workaround you could try the following (typed directly here and untested):

import objc
import pyttx3.drivers.nsss

pyttx3.drivers.nss.super = objc.super

Recent versions of PyObjC should also warn about this when using super in a method definition.

1 Like