Ubuntu: IDLE 2.7.5+ doesn't work in Ubuntu 13.10


Recently, after upgrading from Ubuntu 13.04 to 13.10 I can't open .py files in IDLE 2.7. When I click in "File - Recent Files - file.py" I get an empty window. In this window the code is absent and I can't close it normally, just via "pkill idle" in the terminal.

When I try to open the file.py via terminal with idle:

idle path_to_file/file.py  

I get:

Traceback (most recent call last):

File "/usr/bin/idle", line 5, in <module>      main()  File "/usr/lib/python2.7/idlelib/PyShell.py", line 1536, in main      if flist.open(filename) is None:  File "/usr/lib/python2.7/idlelib/FileList.py", line 36, in open      return self.EditorWindow(self, filename, key)  File "/usr/lib/python2.7/idlelib/PyShell.py", line 131, in __init__      EditorWindow.__init__(self, *args)  File "/usr/lib/python2.7/idlelib/EditorWindow.py", line 323, in __init__      io.loadfile(filename)  File "/usr/lib/python2.7/idlelib/IOBinding.py", line 258, in loadfile      chars = self.decode(chars)  File "/usr/lib/python2.7/idlelib/IOBinding.py", line 296, in decode      enc = coding_spec(chars)  File "/usr/lib/python2.7/idlelib/IOBinding.py", line 129, in coding_spec      for line in lst:  NameError: global name 'lst' is not defined  

I need help, I can't work with my .py files in IDLE !!!

Thanks and Best wishes to all.


This is a known bug. It's fixed in idle 2.7.6, but you can easily(*) fix it yourself.

Open the file /usr/lib/python/idelib/IOBinding.py as root with your favorite editor:

sudo gedit /usr/lib/python2.7/idlelib/IOBinding.py  

Go to line 128 and change:

str = str.split("\n", 2)[:2]  


lst = str.split("\n", 2)[:2]  

and save the file.

(*) Easily if you are a python programmer.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »