Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 -" 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 via terminal with idle:

idle path_to_file/

I get:

Traceback (most recent call last):

File "/usr/bin/idle", line 5, in <module>
File "/usr/lib/python2.7/idlelib/", line 1536, in main
    if is None:
File "/usr/lib/python2.7/idlelib/", line 36, in open
    return self.EditorWindow(self, filename, key)
File "/usr/lib/python2.7/idlelib/", line 131, in __init__
    EditorWindow.__init__(self, *args)
File "/usr/lib/python2.7/idlelib/", line 323, in __init__
File "/usr/lib/python2.7/idlelib/", line 258, in loadfile
    chars = self.decode(chars)
File "/usr/lib/python2.7/idlelib/", line 296, in decode
    enc = coding_spec(chars)
File "/usr/lib/python2.7/idlelib/", 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.

share|improve this question
up vote 3 down vote accepted

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/ as root with your favorite editor:

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

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.

share|improve this answer
Hey, thanks. It works !. How I mark this topic as solved? – Iván Castro Jan 11 '14 at 19:11
There should be a verification mark in my answer to mark it as accepted. – Javier Rivera Jan 11 '14 at 21:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.