1

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'

1
  • 3
    Im sure it shouldnt have worked with v3.9 either. exit() is builtin now. Commented Apr 26, 2022 at 8:39

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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

1 Comment

os.exit() was never a method of os

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.