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

I'm running python 2.7 in Ubuntu 13.10, and idle (idle-python2.7) has stopped working. Whenever I try to open a file in a editor window, it is blank, though the file does exist and is not empty/blank. Furthermore, it is not possible to close idle after this, except via a terminal kill command.

  • Idle was working fine before. The problem appeared after I installed a number of things, including idlex, various scipy modules and mpmath, but after trying to repair it in several ways, it seems to be caused by Ubuntu's official idle package.

I get this error in the terminal when trying to open a file in idle:

Exception in Tkinter callback
[...lines ommitted for brevity...]
File "/usr/lib/python2.7/idlelib/", line 129, in coding_spec
    for line in lst:
NameError: global name 'lst' is not defined

If you look at the code, it looks like an obvious bug: indeed lst is not defined in the function coding_spec. Furthermore, the source file in is different and doesn't show the problem.

Thinking that one of the recently packages had overwritten the file somehow, I've tried a number of things, including reinstalling all Python packages from synaptic, but the wrong is still there. The reason I think the problem lies with the package itself is that I finally did sudo apt-get remove idle, verified that the idlelib directory was empty, and reinstalled with sudo apt-get install idle; but the wrong file came back again.

I can in fact make idle work again by simply replacing lst by str in the code, but to me that's clearly a no-no. I'm not to happy either about trying to replace just that file from the source python distribution, as other files may be wrong. I want to get the right files from the official package.

share|improve this question
I am also having this problem, although I think you mean UBuntu 13.1 – Ravin Nov 11 '13 at 15:57
Edited for 13.10, thanks – adelval Nov 12 '13 at 9:13

It's a 'me too', with no solution.

...until I searched for the specific error.

Edit the file


and replace this line in coding_spec function:

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


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

share|improve this answer
Thanks, but I already mention this solution in the last paragraph of the question. I was hoping there was some official source with the correct, error-free files. – adelval Jan 9 '14 at 18:31

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.