Home > Software design >  Python AttributeError: module 'os' has no attribute 'exit'
Python AttributeError: module 'os' has no attribute 'exit'

Time:04-27

I'm using Python 3.9.12 and I get error in the following line

os.exit()

the Error message is: AttributeError: module 'os' has no attribute 'exit'

CodePudding user response:

os.exit() is not and was not a method of the os module. You may confuse it with os._exit() or sys.exit()

CodePudding user response:

make sure variable os not been overwrited, like filename or varable name ...

CodePudding user response:

As from comment, exit is a built-in. So os.exit() becomes exit()

  • Related