简体   繁体   中英

PyCharm 2019.3 Python Console - Connection timed out

I'm unable to access my Python Console to run scripts. I have just installed PyCharm 2019.3 Pro via JetLab's tar file on a Manjaro Linux 4.19. My license is good. I have set my Python interpreter under Setting>Project>Project Interpreter and Settings>Build...>Console>Python Console . Can't figure what's wrong...

Here's what the Python Console outputs:

/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

It might be that the problematic code is with the socket module call in pydev_transport.py :

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)

It seems that PyCharm sets host=localhost which doesn't seem to work.

For a quick fix, I set host=127.0.0.1 . That is, I edited the main loop in pydevconsole.py and modified the client loop:

    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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM