【问题标题】:PyCharm 2019.3 Python Console - Connection timed outPyCharm 2019.3 Python 控制台 - 连接超时
【发布时间】:2019-12-03 05:52:59
【问题描述】:

我无法访问我的 Python 控制台来运行脚本。我刚刚在 Manjaro Linux 4.19 上通过 JetLab 的 tar 文件安装了 PyCharm 2019.3 Pro。我的驾照很好。我在Setting>Project>Project Interpreter 和Settings>Build...>Console>Python Console 下设置了我的Python 解释器。不知道怎么回事……

以下是 Python 控制台输出的内容:

/home/XXXXX/miniconda3/bin/python /home/XXXXX/bin/pycharm-2019.3/plugins/python/helpers/pydev/pydevconsole.py --mode=client --port=33145
Traceback (most recent call last):
  File "/home/XXXXX/bin/pycharm-2019.3/plugins/python/helpers/pydev/pydevconsole.py", line 482, in <module>
    pydevconsole.start_client(host, port)
  File "/home/XXXXX/bin/pycharm-2019.3/plugins/python/helpers/pydev/pydevconsole.py", line 395, in start_client
    client, server_transport = make_rpc_client(client_service, host, port)
  File "/home/XXXXX/bin/pycharm-2019.3/plugins/python/helpers/pydev/_pydev_comm/pydev_rpc.py", line 11, in make_rpc_client
    client_transport, server_transport = open_transports_as_client((host, port))
  File "/home/XXXXX/bin/pycharm-2019.3/plugins/python/helpers/pydev/_pydev_comm/pydev_transport.py", line 231, in open_transports_as_client
    client_socket.connect(addr)
TimeoutError: [Errno 110] Connection timed out
Process finished with exit code 1

有问题的代码可能与pydev_transport.py 中的socket 模块调用有关:

def open_transports_as_client(addr):
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client_socket.connect(addr)   #Problem here? By the way addr=(host,port)

    return _create_client_server_transports(client_socket)

【问题讨论】:

    标签: python python-3.x pycharm


    【解决方案1】:

    似乎 PyCharm 设置了host=localhost,这似乎不起作用。

    为了快速修复,我设置了host=127.0.0.1。也就是我在pydevconsole.py中编辑了主循环,修改了客户端循环:

        if mode == 'client':
            if not port:
                # port must be set for client
                sys.exit(-1)
    
            if not host:
                from _pydev_bundle import pydev_localhost
                host = client_host = "127.0.0.1" 
                # host = client_host = pydev_localhost.get_localhost()
            pydevconsole.start_client(host, port)
        elif mode == 'server':
            pydevconsole.start_server(port)
    

    【讨论】:

      猜你喜欢
      • 2021-04-27
      • 2016-01-11
      • 1970-01-01
      • 2020-09-20
      • 2016-09-20
      • 1970-01-01
      • 2015-06-17
      • 1970-01-01
      • 2016-04-15
      相关资源
      最近更新 更多