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.

I've already tried to get .py files to open with IDLE by default, but no luck. I've used every trick you may want to suggest. I really just want to open up IDLE and from there open a .py file from a dialogue box. All I get when I try is a blank IDLE screen that won't close no matter what I do. I open it via the terminal so all I have to do is force the terminal to close and it goes away.

I just want to be able to hit ctrl+o and navigate to my file and have it open in an edit mode so I can hit f5 to run it. Anyone have a solution for that?

Python 2.7 Ubuntu 13.10 running Cinnamon.

share|improve this question
add comment

1 Answer 1

You need to edit this file /usr/lib/python2.7/idlelib/IOBinding.py:

def coding_spec(str):
"""Return the encoding declaration according to PEP 263.

Raise LookupError if the encoding is declared but unknown.
"""
# Only consider the first two lines
str = str.split("\n", 2)[:2]
for line in lst:

Replace str with lst:

def coding_spec(str):
"""Return the encoding declaration according to PEP 263.

Raise LookupError if the encoding is declared but unknown.
"""
# Only consider the first two lines
lst = str.split("\n", 2)[:2]
for line in lst:

I had the same problem and this worked for me.

share|improve this answer
add comment

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.