gpt4 book ai didi

python - Pycharm python 控制台 socket.gaierror

转载 作者:行者123 更新时间:2023-11-28 19:55:03 25 4
gpt4 key购买 nike

我在 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有空格,这里不是这样的(host has been assigned to '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))

最佳答案

到目前为止给出的答案没有找到根本原因,这很可能是您的 OS X /etc/hosts 文件不包含以下条目:127.0.0.1 localhost

使用以下行更新主机文件:
127.0.0.1 本地主机
(您将需要使用 sudo),然后重新启动 pyCharm。除非您知道自己在做什么,否则编辑 IDE 源代码并不是一个好主意。

关于python - Pycharm python 控制台 socket.gaierror,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31844342/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com