【问题标题】:How to use python console in Pycharm using Docker for Mac如何在 Pycharm 中使用 Docker for Mac 使用 python 控制台
【发布时间】:2018-10-31 00:06:08
【问题描述】:

当我使用 docker compose 在 pycharm 中运行 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      

【问题讨论】:

  • 假设你要连接的服务器叫web,你在终端里试过docker-compose exec web python吗?你应该能够连接到 web 容器内的 python 控制台
  • @NourChawich 是的,我可以通过 docker 命令连接到 python。问题是通过Pycharm python console 的连接。我是在linux机器上做的,但是在macos上做不到。

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2020-07-21
    • 2013-06-08
    • 2023-04-07
    • 1970-01-01
    • 2018-12-06
    • 1970-01-01
    • 2017-06-23
    • 2010-09-21
    • 2015-06-17
    相关资源
    最近更新 更多