Advice for wxPython error: "'NoneType' object is not callable" in ignored

Follower follower at
Sun Mar 2 01:46:50 CET 2003

This post is about an issue relating to wxPython, module importing and
global variables referring to (native?) wxWindows objects. (It is
mostly intended  as Google-bait for anyone else having the problem in
the future, but any further information is welcome.)

The following Python error message may indicate you have this problem:

Exception exceptions.TypeError: "'NoneType' object is not callable" in

Simplest Problem Form
You have these files:

With the following content:

# ---- ----
import mypackage.mymodule

# ---- mypackage/ ----
# <empty>

# ---- mypackage/ ----
import wxPython.wx

import mypackage  # <1>

myglobal = wxPython.wx.wxSize(780, 580) 

# -- <end> --

When you execute the command:


The following is the output:

Exception exceptions.TypeError: "'NoneType' object is not callable" in

* Don't have global variables ('myglobal' in this example) referring
to wxWindows objects. (Best solution.)

* Don't explictly import the parent package from a module within it.
(i.e. delete the line marked with "<1>"--it's not necessary in real
life anyway.) While this solves the problem in certain circumstances
you may run into the problem again if you have sub-packages which
import the parent package.

Explanation (as far as I understand things)
Error messages of the form "<foo> in <bar> ignored" are generated when
an exception occurs in an object's __del__() method. (In this case it
would seem Python can't identify where the exception occurred which is
why "<bar>" is blank, leaving the message "<foo> in  ignored".)

The actual message indicates there are issues with the order of object
deletion with wxPython and global variables referring to
wxPython/wxWindows objects.

Other Resources
See also particularly these messages on the 'wxPython-users' mailing

* "[wxPython-users] Errors when app is closed by logging out",

* "[wxPython-users] weird bug with imports",

Hope this saves someone some time. :-)

More information about the Python-list mailing list