Docker远程上的Pycharm远程解释器:[Errno 2]没有此类文件或目录 [英] Pycharm Remote interpreter on Docker remote: [Errno 2] No such file or directory

查看:336
本文介绍了Docker远程上的Pycharm远程解释器:[Errno 2]没有此类文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题中所指定的,我正在尝试将Pycharm Professional(2018.2)与python远程解释器一起使用,该python解释器位于局域网中远程服务器上托管的Docker计算机中。我通过遵循帮助' https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html '。

As specified in the title I am trying to use Pycharm Professional (2018.2) with a python remote interpreter in a Docker machine hosted on a remote server in my LAN. I created a very simple example by following the help 'https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html'.


  • Pycharm 2018.2已安装在debian发行版的LAN pc(192.168.1.10)上;

  • Docker已安装在LAN debian服务器(192.168.1.22)

我能够将Docker配置为远程解释器,以通过Pycharm工具与Docker服务连接,但是当我尝试运行时(或调试)Docker容器中的main.py我总是这样:

I was able to configure Docker as a remote interpreter, to connect with the Docker service through the Pycharm tool but when I try to run (or debug) the main.py in the Docker container I always get this:

37073edcd9d2:python -u /opt/project/main.py (null): can't open file '/opt/project/main.py': [Errno 2] No such file or directory
Process finished with exit code 2

执行当然是在远程Docker容器中完成的,但似乎文件将被执行d未找到。我按照各种博客所述,以各种可能的方式手动附加了本地卷,但是我总是遇到相同的错误。
这些是我的配置的一些规范:
docker工具设置

The execution is certainly done in the remote Docker container but it seems that the file to be executed is not found. I manually attached the local volume as described on various blogs with all possible variations but I always get the same error. These are some specifications of my configuration: docker tool setting

项目解释器设置

运行/调试配置

带有音量的Docker容器设置映射到运行/调试配置

缺少什么?

坦克。谢谢您的帮助!

推荐答案

问题出在Pycharm的限制下,即在远程主机上管理docker计算机。引擎盖。在运行/调试配置中插入卷映射时,它被解释为本地路径,因此,在这种情况下,它是远程服务器上必须存在的路径。因此,目前,唯一的选择是通过首先通过SSHFS或NFS服务共享本地路径(项目所在的文件夹)将其安装在Docker服务的远程主机上。
所以...(1)我使用NFS共享了Pycharm项目文件夹(本地计算机ip 192.168.1.10); (2)我将共享文件夹安装在服务器主机上(在服务器IP 192.168.1.22上; mount -t nfs 192.168.1.10:/home/user/PythonProjects/home/ext-user/mnt/projects ),然后(3)在Pycharm的运行/调试配置中,我将卷与远程服务器上安装的路径映射了起来。运行。该程序现在可以正常运行了。 [运行结果]

The problem lies in the Pycharm 'limit' of managing a docker machine on a remote host 'under the hood'. When inserting the volume mapping in the run / debug configuration, it is interpreted as a local path and therefore, in this case, a path that must be present on the remote server. So, for now, the only option is to mount the local path (the folder where the project is located) on the remote host of the Docker service by first sharing it through an SSHFS or NFS service. So ... (1) I shared the Pycharm project folder (local machine ip 192.168.1.10) using NFS; (2) I mounted the shared folder on the server host (on server ip 192.168.1.22; mount -t nfs 192.168.1.10:/home/user/PythonProjects /home/ext-user/mnt/projects) then (3) in the run / debug configuration of Pycharm I mapped the volumes with the path mounted on the remote server ... Run ... the program now runs without any errors. [Run result]

以下是我的新配置的一些规范:

These are some specifications of my new configuration:

运行/调试配置

具有将卷映射到运行/调试配置的docker容器设置

我希望该解决方案对其他人有用。我也希望有比我更好的解决方案:-)

I hope the solution can be useful to other people. I also hope that there are better solutions than mine :-)

这篇关于Docker远程上的Pycharm远程解释器:[Errno 2]没有此类文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆