2013-12-17 184 views
2

我在Windows 7上運行Python 2.7.2。最近我無法直接打開IDLE。當我在命令行中運行Python並導入idlelib.idle我得到這個錯誤:IDLE不會啓動;文件中出現意外的Unicode字符

>>> import idlelib.idlepython`.exe 
Traceback (Most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "C:\Python27\lib\idlelib\idle.py", line 10, in <module> 
    import idlelib.PyShell 
    File "C:\Python27\lib\idlelib\PyShell.py", line 26, in <module> 
    from idlelib.EditorWindow import EditorWindow, fixwordbreaks 
    File "C:\Python27\lib\idlelib\EditorWindow.py", line 68, in <module> 
    class EditorWindow(object): 
    File "C:\Python27\lib\idlelib\EditorWindow.py", line 69, in EditorWindow 
    from idlelib.Percolator import Percolator 
    File "C:\Python27\lib\idlelib\Percolator.py", line 1, in <module> 
    from idlelib.WidgetRedirector import WidgetRedirector 
    File "C:\Python27\lib\idlelib\WidgetRedirector.py", line 109 
    root.w↨+ 
     ^
SyntaxError: invalid syntax 

我該如何解決這個問題?

+0

'root.w'後面的箭頭字符是'U + 21a8'。我會說'WidgetRedirector.py'文件可能已損壞。 – jadkik94

+1

確保第109行讀取'C:\ Python27 \ lib \ idlelib \ WidgetRedirector.py'中的'root.wm_protocol(「WM_DELETE_WINDOW,root.quit)'。如果沒有,重新安裝Python或只是IDLE。 – jadkik94

+0

有趣的是,我最近有過類似的事情發生在我身上,但我使用了Python 3.3.3。我不確定這是否對你來說太重要了,因爲你可能不得不重新下載東西,但是爲我解決的是重新安裝Python。 –

回答

0

Make sure the line 109 reads

root.wm_protocol("WM_DELETE_WINDOW", root.quit) 

in C:\Python27\lib\idlelib\WidgetRedirector.py .

If not, re-install Python or just IDLE.

從jadkik94,在評論中。