如何使用Docker for Mac在Pycharm中使用python控制台

时间:2018-05-21 10:39:09

标签: python-3.x macos docker-compose pycharm docker-for-mac

当我在pycharm中使用docker compose运行docker-compose应用程序时,我无法连接到python控制台。所有的配置似乎都很好。 Pycharm扫描解释器的所有要求。但是当我打开python console时出现错误:

    018, 21:07:40) 
  [GCC 6.3.0 20170516] on linux
  Traceback (most recent call last):
  File "/opt/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 303, in run
    self._on_run()
  File "/opt/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 1521, in _on_run
    self.send_result(xml)
  File "/opt/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 1543, in send_result
    self.frame_accessor.ReturnFullValue(self.seq, xml.getvalue())
  File "/opt/python3.6/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "/opt/python3.6/lib/python3.6/xmlrpc/client.py", line 1452, in __request
    verbose=self.__verbose
  File "/opt/python3.6/lib/python3.6/xmlrpc/client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/opt/python3.6/lib/python3.6/xmlrpc/client.py", line 1166, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
  File "/opt/python3.6/lib/python3.6/xmlrpc/client.py", line 1279, in send_request
    self.send_content(connection, request_body)
  File "/opt/python3.6/lib/python3.6/xmlrpc/client.py", line 1309, in send_content
    connection.endheaders(request_body)
  File "/opt/python3.6/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/opt/python3.6/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/opt/python3.6/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/opt/python3.6/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/opt/python3.6/lib/python3.6/socket.py", line 704, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/opt/python3.6/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
  socket.gaierror: [Errno -2] Name or service not known      

我已经尝试了很多不同的解决方案,但没有人帮助我

1 个答案:

答案 0 :(得分:0)

此问题已解决。 Pycharm可以通过python控制台连接到docker-compose解释器