Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Recently, after upgrade from Ubuntu 13.04 to 13.10 I can open .py files in IDLE 2.7. When I doing click in "File - Rencet Files - file.py" I get a empty windows. In this windows 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.

share|improve this question

1 Answer 1

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/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]

to:

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 at 19:11
    
There should be a verification mark in my answer to mark it as accepted. –  Javier Rivera Jan 11 at 21:45

Your Answer

 
discard

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.