Python IDLE无法打开
我在打开IDLE的时候遇到了问题——我只能通过右键点击PY文件,然后选择“用IDLE编辑”来打开它。我现在使用的是Python 2.6.4。我试过用命令'python.exe Lib\idlelib\idle.py'来打开,但出现了一些错误:
C:\Python26>python.exe Lib\idlelib\idle.py
----------------------------------------
Unhandled server exception!
Thread: SockThread
Client Address: ('127.0.0.1', 8833)
Request: <socket._socketobject object at 0x0248CD18>
Traceback (most recent call last):
File "C:\Python26\lib\SocketServer.py", line 281, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python26\lib\SocketServer.py", line 307, in process_request
self.finish_request(request, client_address)
File "C:\Python26\lib\SocketServer.py", line 320, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python26\lib\idlelib\rpc.py", line 503, in __init__
SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr)
File "C:\Python26\lib\SocketServer.py", line 615, in __init__
self.handle()
File "C:\Python26\lib\idlelib\run.py", line 256, in handle
import IOBinding
File "C:\Python26\lib\idlelib\IOBinding.py", line 12, in <module>
import tempfile
File "C:\Python26\lib\tempfile.py", line 34, in <module>
from random import Random as _Random
ImportError: cannot import name Random
*** Unrecoverable, server exiting!
----------------------------------------
Traceback (most recent call last):
File "Lib\idlelib\idle.py", line 21, in <module>
idlelib.PyShell.main()
File "C:\Python26\lib\idlelib\PyShell.py", line 1400, in main
shell = flist.open_shell()
File "C:\Python26\lib\idlelib\PyShell.py", line 281, in open_shell
if not self.pyshell.begin():
File "C:\Python26\lib\idlelib\PyShell.py", line 989, in begin
client = self.interp.start_subprocess()
File "C:\Python26\lib\idlelib\PyShell.py", line 404, in start_subprocess
self.transfer_path()
File "C:\Python26\lib\idlelib\PyShell.py", line 486, in transfer_path
\n""" % (sys.path,))
File "C:\Python26\lib\idlelib\PyShell.py", line 696, in runcommand
self.rpcclt.remotequeue("exec", "runcode", (code,), {})
File "C:\Python26\lib\idlelib\rpc.py", line 216, in remotequeue
return self.asyncreturn(seq)
File "C:\Python26\lib\idlelib\rpc.py", line 240, in asyncreturn
response = self.getresponse(seq, wait=0.05)
File "C:\Python26\lib\idlelib\rpc.py", line 280, in getresponse
response = self._getresponse(myseq, wait)
File "C:\Python26\lib\idlelib\rpc.py", line 300, in _getresponse
response = self.pollresponse(myseq, wait)
File "C:\Python26\lib\idlelib\rpc.py", line 428, in pollresponse
self.handle_EOF()
File "C:\Python26\lib\idlelib\PyShell.py", line 334, in handle_EOF
raise EOFError
EOFError
C:\Python26>
任何帮助都非常感谢。
2 个回答
1
我知道这个问题很早就有人问过了,但我找到了一些不错的资料,可能对有类似问题的人有帮助:https://community.activestate.com/node/12746
简单来说,就是需要把tl和tk这两个文件夹复制粘贴到Python的lib文件夹里。
希望这能帮到你,
4
PEBKAC: 我之前傻乎乎地创建了一个叫 random.py 的文件,并把它放在了 Python26 这个文件夹里。
现在问题解决了,谢谢。