On 8/8/07, Jameson Chema Quinn <[EMAIL PROTECTED]> wrote: > > > > > > This is all very strange behavior. > > > > Please try the following: > > 1. Replace all instances of 'idlelib' into 'jqidlelib', including > > appearances inside strings. There should be two of these in PyShell.py > > and two in idle.py. Also, make sure it doesn't appear in run.py either > > (if it does, change it there too.) > > 2. Rename/move the normal idlelib directory (temporarily) > > 3. Close all existing instances of IDLE (and make sure no zombie > > Python processes are still running in the background) > > 4. Try running your version of IDLE again > > > > If IDLE still crashes, please send the tracebacks. > > > > - Tal > > > > I think you misunderstand. The problem occurs, not when I run my script from > the shell or from some other IDE, but when I run it from within IDLE. This > makes it more understandable - but it is still a bug. Perhaps it's OK if you > can't edit IDLE from within IDLE, but you should not get funny behaviour > every time you load a module that happens to share a name with an IDLE > module. > > Jameson >
I think I understand the problem now - you're editing your version of IDLE with the existing version, and you're having module importing issues. The problem is that when you run a Python script, the interpreter adds the script's directory to the beginning of sys.path. This means the when you do "import <module_name>", Python will go through the directories in sys.path searching for a file by that name, and so it will find first and use anything in the directory from where the script was run. This is true for IDLE as well, and I can see now how this can cause problems. What you should do is run IDLE without adding its directory to sys.path. Here's a quick way to do so from the command line: python.exe -c "import idlelib.PyShell; idlelib.PyShell.main()" Just run this from a directory which has nothing Python-related in it, and you'll have no such importing issues. To completely ignore the directory from which Python was run, use: python.exe -c "import sys; del sys.path[0]; import idlelib.PyShell; idlelib.PyShell.main()" Another way would be to remove the directory from sys.path after IDLE has started, inside IDLE's shell. However, it may not be the first item in the sys.path list, because IDLE sometimes adds more directories to sys.path. Anyways, sorry for taking a while to understand the issue and hoping the above helps, - Tal _______________________________________________ IDLE-dev mailing list [email protected] http://mail.python.org/mailman/listinfo/idle-dev
