Unrequested dialog box using Python on one system

It runs fine on another system. The issue is related to networkx when running a file or using Visual Studio Code. The simple "import networkx’ generates a dialog box (generated it appears from PySimpleGUI).
When the X is clicked in the upper right hand corner, another dialog box is popped-up with the heading “error creating layout window”. The dialog is from PySimpleGUI. PySimpleGui is not being imported so I have not idea what has triggered it.

The only way to get rid of the dialog box it through the use of Task Manager.

I do have PySimpleGUI on the system and I have used it in other applications.

I posted a lot more detail about my investigations as issue #4232 at https://github.com/networkx/networkx/issues.

I came to the conclusion that Python has been changed, but I do not know where to look or how to undo what is happening. Any help would be appreciated.

I just moved the code to a new directory and it ran fine. I copied it and pasted it into the original directory, ran the code, the phantom dialog box popped up and the application hung.

So it looks like python is loading something from the original directory which is causing the problem. Curiouser and curiouser.

Look inside the original directory. What’s there?

In particular, look for a file with the same name as a module that your
code is otherwise importing.

Thanks. I have been doing that but I haven’t figured it out yet.

Start by listing all the .py files in the directory.

What are they?

I have done that and I am looking at them to see which ones might be involved. Worse comes to worse, I will copy the directory and then remove the py files one by one until I identify the pertinent one and then examine to see what is causing the generation of dialog. I will post what I find out.

Found it. I had a file named html.py which contained an import of PySimpleGUI which caused the problem. This is a gotcha of Python - having a file name be interpreted as a module. Sometimes this comes in handy but this time it bit me. I will need to be more careful with file naming. I renamed the file from html.py to html1.py.

Has anyone written a module to do name checking in a directory to warn people that a particular file name is potentially dangerous? That would make Python easier on new users - which has been one of it’s selling points. The PySimpleGUI error dialog does not mention this as a possibility which for this error case has not been very helpful.