【发布时间】:2016-12-27 20:35:43
【问题描述】:
我在 OS X Yosemite (10.10.3) 上运行 Pycharm 4.5.3。我创建了一个简单的 python 程序,并尝试打开 python 控制台,并得到这个堆栈跟踪错误:
/usr/bin/python -u /Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py 59286 59287
Error starting server with host: localhost, port: 59286, client_port: 59287
Unhandled exception in thread started by <function start_server at 0x100d9bd70>
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py", line 283, in start_server
server = XMLRPCServer((host, port), logRequests=False, allow_none=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SimpleXMLRPCServer.py", line 593, in __init__
SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 419, in __init__
self.server_bind()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Couldn't connect to console process.
这里在堆栈溢出时提出了类似的问题,但错误的根源是带有空格的字符串 localhost 传入,这里不是这种情况(主机已分配给“localhost”)。有人有什么主意吗?这没什么大不了的,因为我可以在终端中使用 python 命令行,但我很好奇这是否是 Pycharm 中的错误。
编辑:这是 Pycharm 脚本的源代码。
if __name__ == '__main__':
import pydevconsole
sys.stdin = pydevconsole.BaseStdIn()
port, client_port = sys.argv[1:3]
import pydev_localhost
if int(port) == 0 and int(client_port) == 0:
(h, p) = pydev_localhost.get_socket_name()
client_port = p
pydevconsole.StartServer(pydev_localhost.get_localhost(), int(port), int(client_port))
【问题讨论】:
-
“127.0.0.1”有效吗?
-
您能否也发布引发此异常的程序的相关部分。
-
@Totem 这是用于启动pydev控制台的内部pycharm脚本,所以无法更改内部代码。我在 main 中查看了他们的源代码,并将其发布在 main 代码框中。
-
@HaleemurAli 这就是与该程序相关的所有内容。只需单击 PyCharm 工具栏,即可抛出此问题。我自己没有编写任何代码来实现这一点。