简体   繁体   English

Docker远程上的Pycharm远程解释器:[Errno 2]没有此类文件或目录

[英]Pycharm Remote interpreter on Docker remote: [Errno 2] No such file or directory

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. 正如标题中所指定的,我正在尝试将Pycharm Professional(2018.2)与局域网中远程服务器上托管的Docker机器中的python远程解释器一起使用。 I created a very simple example by following the help ' https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html '. 我按照帮助' https://www.jetbrains.com/help/pycharm/using-docker-as-a-remote-interpreter.html '创建了一个非常简单的示例。

  • Pycharm 2018.2 is installed on a LAN pc (192.168.1.10) on a debian distro; Pycharm 2018.2安装在debian发行版的LAN PC(192.168.1.10)上;
  • Docker is installed on a LAN debian server (192.168.1.22) Docker安装在LAN debian服务器(192.168.1.22)上

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: 我能够将Docker配置为远程解释器,以通过Pycharm工具与Docker服务连接,但是当我尝试运行(或调试)Docker容器中的main.py时,我总是得到以下信息:

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

The execution is certainly done in the remote Docker container but it seems that the file to be executed is not found. 执行当然是在远程Docker容器中完成的,但是似乎找不到要执行的文件。 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工具设置

project interpreter setting 项目解释器设置

Run/Debug Configuration 运行/调试配置

docker container setting with volume mapping into Run/Debug Configuration 将docker容器设置与卷映射到Run / Debug Configuration中

Is missing something? 缺少什么吗?

Tanks. 战车 Any help is appreciated! 任何帮助表示赞赏!

The problem lies in the Pycharm 'limit' of managing a docker machine on a remote host 'under the hood'. 问题在于在后台管理远程主机上的docker计算机的Pycharm“限制”。 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. 因此,目前,唯一的选择是通过首先通过SSHFS或NFS服务共享本地路径(在项目所在的文件夹)来将本地路径安装在Docker服务的远程主机上。 So ... (1) I shared the Pycharm project folder (local machine ip 192.168.1.10) using NFS; 所以...(1)我使用NFS共享了Pycharm项目文件夹(本地计算机ip 192.168.1.10); (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. (2)我将共享文件夹安装在服务器主机上(在服务器IP 192.168.1.22上;在mount -t nfs 192.168.1.10:/home/user/PythonProjects /home/ext-user/mnt/projects ),然后在(3)中Pycharm的运行/调试配置我将卷与远程服务器上安装的路径进行了映射...运行...该程序现在可以正常运行了。 [ Run result ] [ 运行结果 ]

These are some specifications of my new configuration: 这些是我的新配置的一些规范:

Run/Debug Configuration 运行/调试配置

docker container setting with volume mapping into Run/Debug Configuration 将docker容器设置与卷映射到Run / Debug Configuration中

I hope the solution can be useful to other people. 我希望该解决方案对其他人有用。 I also hope that there are better solutions than mine :-) 我也希望有比我更好的解决方案:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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