当我尝试使用 pydoc 查看 python 文档时出现了这个奇怪的错误。
$ pydoc -p 10000
pydoc server stopped
Traceback (most recent call last):
File "/usr/bin/pydoc", line 5, in <module>
pydoc.cli()
File "/usr/lib/python2.7/pydoc.py", line 2281, in cli
serve(port, ready, stopped)
File "/usr/lib/python2.7/pydoc.py", line 2057, in serve
DocServer(port, callback).serve_until_quit()
File "/usr/lib/python2.7/pydoc.py", line 2039, in __init__
self.base.__init__(self, self.address, self.handler)
File "/usr/lib/python2.7/SocketServer.py", line 408, in __init__
self.server_bind()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.7/SocketServer.py", line 419, in server_bind
self.socket.bind(self.server_address)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno -2] Name or service not known
我尝试重新安装 Python 并尝试了几个不同的端口,但都无济于事。另外
$ python -m SimpleHTTPServer
运行正常。我不太清楚为什么会发生这种情况,可能是因为某个 bug 吗?