pycharm无法完成D的远程解释器设置

2024-05-16 01:49:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我是Docker的新手。我正在使用Docker&Docker compose,学习烧瓶教程。基本的docker图片是Python2.7 slim。 它在Linux上运行。码头工人1.11.2 应用程序运行良好。 我想让pycharm pro连接到远程解释器,这是我以前从未做过的事情。

我按照docker compose的指示操作。最初它失败了,因为它无法连接到端口2376。我把这个端口添加到docker-compose.yml,错误消失了。 但是,尝试保存配置时,会出现“获取远程解释器版本”对话框,从而暂停/挂起。这永远不会结束。还有,我不能放弃小妖精。这发生在Pycharm 2016.2和2016.3 EAP(第二次)。

帮助中说“将帮助程序复制到服务器需要SFTP支持”。 这是否意味着我需要做些什么?


Tags: 端口composedocker程序运行远程烧瓶linux图片
2条回答

我没有用docker机器 问题是默认情况下,在ubuntu 16.04下没有建立对docker API的TCP访问。

有人建议启用TCP/IP访问。

然而,JetBrains给了我最简单的解决方案:

If you are using Linux it is most likely that Docker installed with its default setup and Docker is expecting to be used through UNIX domain file socket /var/run/docker.sock. And you should specify unix:///var/run/docker.sock in the API URL field. Please comment whether it helps!

这个建议适用于我的Ubuntu16.04派生发行版。

这将进入构建、执行、部署下PyCharm preferences中的Docker条目。

您也可以在设置远程解释器时编辑此项,但只能通过创建新的Docker条目。

TCP/IP方法

如果您想要TCP/IP访问,此方法可以工作,但这是一个安全风险。socket方法更好,这可能就是它是默认方法的原因。

https://coreos.com/os/docs/latest/customizing-docker.html

Customizing docker

The Docker systemd unit can be customized by overriding the unit that ships with the default CoreOS settings. Common use-cases for doing this are covered below.

Enable the remote API on a new socket

Create a file called /etc/systemd/system/docker-tcp.socket to make Docker available on a TCP socket on port 2375.

[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=2375
BindIPv6Only=both
Service=docker.service

[Install]
WantedBy=sockets.target

Then enable this new socket:

systemctl enable docker-tcp.socket
systemctl stop docker
systemctl start docker-tcp.socket
systemctl start docker

Test that it’s working:

docker -H tcp://127.0.0.1:2375 ps

有一次我想搜索ubuntu 16.04,我发现了更简单的解决方案,但我没有测试它们。

例如:

https://www.ivankrizsan.se/2016/05/18/enabling-docker-remote-api-on-ubuntu-16-04/

Edit the file /lib/systemd/system/docker.service

Modify the line that starts with ExecStart to look like this:

ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:2375

Where my addition is the “-H tcp://0.0.0.0:2375” part. Save the modified file. Restart the Docker service:

sudo service docker restart

Test that the Docker API is indeed accessible:

curl http://localhost:2375/version

我-docker组成

我认为PyCharm将运行docker-compose up,您是否已尝试在终端(您的docker-compose.yml所在的位置)中首先运行此命令?

也许如果发生错误,你会在你的终端上得到更多的信息。

II-pycharm docker配置

否则可能是因为你在PyCharm中的docker机器配置。

如何配置我的计算机并确保此计算机配置正确:

1-在shell中运行docker-machine ls

enter image description here

2-复制粘贴不带tcp://的url

3-转到pycharm首选项->;Build, Execution, Deployement->;Docker->;+要创建新服务器,请填写服务器name字段

enter image description here

4-粘贴以前复制的url,保持https://

5-填写计算机证书文件夹的路径

6-勾选Import credentials from Docker Machine

7-单击Detect->;您的计算机应显示在选择列表中

8-保存此服务器

9-在配置远程解释器时,从PyCharm首选项中选择此服务器->;Project->;Project Interpreter->;wheel->;add remote->;DockerDocker Compose

enter image description here

10-您应该能够选择服务名称

11-保存你的新翻译

11-尝试运行测试两次,有时初始化可能需要时间

相关问题 更多 >