Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Every time my Python program ends, I get the following:

close failed in file object destructor:
IOError: [Errno 9] Bad file descriptor
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/", line 66, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
RuntimeError: sys.meta_path must be a list of import hooks

Apport presumes it won't be the cause of more problems in case something goes wrong. In my case however, Apport seems to be a big problem.

I'm on a system where I'm just one of many programmers, and I don't have root privileges. So I'd like to make my Python program simply turn Apport off, but not turn Apport off globally.

How do I disable Apport for my user account?

share|improve this question

This looks like a problem in Apport. I'd fill a bug, because there is no guarantee that you program won't fail on different environment if it causes Apport to crash.

If you really want to disable Apport for your program, try this:

if sys.excepthook != sys.__excepthook__:
   print("Warning: 3rd party exception hook is active")
   if sys.excepthook.__name__ == 'apport_excepthook':
       print("         killing Ubuntu's Apport hook")
       sys.excepthook = sys.__excepthook__
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.