IDLE "module browser" not working


I’m facing an issue when using IDLE. When trying to use the module browser (alt+c) to get an overview of my classes, a window opens but stays blank. The only thing that shows is the name of my file, but the rest of the tree is missing. When I hover my cursor on the window, I get the Windows blue circle indicating that something is loading, but it never completes.

I have tried it with files that are natively in the python library to make sure it was not a problem specific to my file, but it does not work with any file.

I’m on Windows 11 Home. I have tried uninstalling python and reinstalling the latest version. I have tried doing a repair of the install. Nothing has worked so far.

Thank you for your help.

Give this a shot (assuming you have your active .py script file open):

  1. Options > Configure IDLE
  2. Make sure that IDLE Classic Windows is selected.
  3. Click Apply > Ok.


Hi Paul,

Thank you for your reply. I tried what you suggested but unfortunately it did not work.

Kind regards

That is odd. Is the key-pair included in the key set?

Yes it is. And the key alt+c does open it, but it somehow seems to fail to load.

Ok, figured it out by looking at the filename. For some reason, of which I don’t know, it does not like the dunder naming convention (double underscores on both sides of the file name). If you temporarily name it sam (or whatever temp name that you wish to give it or just remove the underscores from the filename) for now, it will work.

fyi, if you’re interested in having that information on the fly, download PyCharm.

I tried IDLE on Win10 with latest installed 3.11, 3.12, and 13.13 and with updated local main build, each after opening tkinter.__init__ with File=>Open Modue. By ‘latest version’ do you mean 3.12.2 (which I used)? File=> Module Browser works fine for me.

I am IDLE maintainer. Please run IDLE from Command Prompt with py -m idlelib. Run module browser on a file with def and class statements, as you did above. Do you see any messages in Command Prompt?
Open idlelib.browser with File=>Open Module (Alt-M). Run it with F5. This should run the browser unittests as well as opening a window with the module browser run on itself.

You could also try saving a backup of and add some debug prints to the file to see where it is hanging, if it is. Print output should appear in CommandPrompt. Start with the listchildren message before and after the pyclbr call.

Paul posted just before me. I temporarily added a minimal def f(): pass to both and in idlelib/. The former worked fine, the latter did not. I traced this to util._find_spec_from_path('__main__') raising ValueError: __main__.__spec__ is None instead of returning the __main__ equivalent of

ModuleSpec(name='__init__', loader=<_frozen_importlib_external.SourceFileLoader object at 0x000001C6C2462DB0>, origin='C:\\Programs\\Python313\\Lib\\idlelib\\')

I will open a tracker issue.

Hi both,

Thanks for your replies.

I have done some testing and it seems that having __ in the file does have an impact, although it does not have to be in the file name itself (see first image). Having it in the code also seems to make the MB buggy. I have not been able to isolate the exact issue, but it seems that even having __ in the code and then removing it has an impact (see second image after __ removal MB is still buggy). I have also created another test file for which the MB kind of works but does not quite display properly (see third image)

I am running v3.11.9 as it is listed as the latest “stable” version here Python Releases for Windows |

Please see below the error messages I get from images 1 and 2 (I get the same error even after removing the “__”). For image 3 I do not get an error even though the display is not quite right.

Thank you for your help.

Exception in Tkinter callback
Traceback (most recent call last):
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\”, line 1967, in call
return self.func(*args)
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 176, in handler
r = li
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 782, in open_module_browser
browser.ModuleBrowser(self.root, filename)
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 96, in init
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 132, in init
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 156, in expand
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 195, in update
self.draw(7, 2)
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 210, in draw
sublist = self.item._GetSubList()
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 368, in _GetSubList
sublist = self.GetSubList()
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 169, in GetSubList
return [ChildBrowserTreeItem(obj) for obj in self.listchildren()]
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\idlelib\”, line 190, in listchildren
tree = pyclbr.readmodule_ex(name, [dir] + sys.path)
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\”, line 119, in readmodule_ex
return _readmodule(module, path or )
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\”, line 183, in _readmodule
return _create_tree(fullmodule, path, fname, source, tree, inpackage)
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\”, line 271, in _create_tree
File “C:\Users\pierr\AppData\Local\Programs\Python\Python311\Lib\”, line 50, in parse
return compile(source, filename, mode, flags,
File “”, line 4
def def():
SyntaxError: invalid syntax

It appears that it doesn’t like the naming of functions using keyword names which is general programming practice. In your test code, it shows that you named a function using the same name as a keyword. This is the source of the error for this particular instance.

When I renamed the function name to other than a keyword name, it appears to work fine.
Takeaway, don’t use keyword names when naming functions, classes, variables, etc.


In the other file, there is a misspelling:


Image 3 looks correct to me as far as I can tell from the image. You have to click the [+] for class Test2 to see its methods.

The fact that people misidentify the source of a problem is why one should try to strip code down to the minimum needed to show the problem. True whether debugging oneself or posting for help.

The fact that MB hangs when there is a syntax error is a bug, separate from the __main__ issue, in either pyclbr or idlelib.browser or possibly both. pyclbr once had its own parsing code, which passed over most syntax errors. A couple of years ago we switched to using ast.parse, which had the side effect of instead raising. The integration does not handle that possibility properly.

1 Like

Regarding image 3, what I meant is that the bottom half of the text is truncated. Not a big deal though, still readable.

Apologies for the syntax error in the example I uploaded. Just FYI, the root cause of my problem was actually that I was using a dot in the name of my file (draft v1.08). When changed to draft v108 it works fine. I had not mentioned the original name of my file with a dot since Paul had identified the main issue and I was also using main as a function in my code, I replicated it by creating new test files while having no idea that the dot was also an issue.

So to summarize, it seems there are at least 4 things that make the MB crash:

  • using __ main __ in the name of the file

  • using a dot in the name of the file

  • using keyword names for functions (which was just a dumb example on my part and should of course never be done)

  • having a syntax error in the code

I thank you both for your help on this matter. I think this topic can be closed.

Add the following to your list:

  • Don’t use blank spaces when naming filenames or folders

I opened #117742 and #117743.