[英]Running a Docker image in PyCharm causes “Invalid volume specification”
I am trying to run a project based on a Docker Image (Tensorflow, following instructions from this tutorial ) as described in this blog . 我正在尝试运行一个基于Docker映像的项目(Tensorflow,按照本教程的说明进行操作),如本博客所述 。 The Docker is running fine, but I'm unable to import it in PyCharm (professional, does not work in community version).
Docker运行良好,但是我无法将其导入PyCharm(专业,在社区版本中不起作用)。 I get the following error message:
我收到以下错误消息:
Error running main: Can't run remote python interpreter: {"message":"Invalid bind mount spec \\"C:/Path-to-project/Project-name:/opt/project:rw\\": Invalid volume specification: 'C:/Path-to-project/Project-name:/opt/project:rw'"}
运行main时出错:无法运行远程python解释器:{“ message”:“无效的绑定安装规范\\” C:/项目路径/项目名称:/ opt / project:rw \\“:无效的卷规范: 'C:/项目路径/项目名称:/ opt / project:rw'“}
How to solve this? 如何解决呢?
This is a Windows Linux path problem. 这是Windows Linux路径问题。 To solve it, change project paths to the Docker file to
/c/Path-to-project/Project-name
(with a lower case c and forward slashes) in order to solve this problem. 要解决此问题,请将Docker文件的项目路径更改为
/c/Path-to-project/Project-name
(使用小写的c和正斜杠)以解决此问题。 Inspired by this link . 受此链接启发。
I solved this problem as follows: 我解决了这个问题,如下所示:
File -> Settings -> Project -> Project Interpreter -> Your docker interpreter -> Path mappings
; File -> Settings -> Project -> Project Interpreter -> Your docker interpreter -> Path mappings
; {'Local path': 'C:', 'Remote path': '/c'}
(replace to your drive with project; if you use this interpeter for several projects from differen drives then add them all); {'Local path': 'C:', 'Remote path': '/c'}
(用项目替换为驱动器;如果将此插值器用于来自不同驱动器的多个项目,则将它们全部添加); Run -> Edit Configurations -> Your configuration -> Docker container settings -> '...' -> Volume bindings
; Run -> Edit Configurations -> Your configuration -> Docker container settings -> '...' -> Volume bindings
; {'Container path': '/opt/project', 'Host path': 'C:\\Users\\_username_\\my_python_project'}
) and press ' Edit '. {'Container path': '/opt/project', 'Host path': 'C:\\Users\\_username_\\my_python_project'}
),然后按' Edit '。 OK -> Apply -> OK
. OK -> Apply -> OK
。 If first ' OK ' without changes did not help then replace 'Host path': 'C:\\Users\\_username_\\my_python_project'
to 'Host path': '/c/Users/_username_/my_python_project'
; 'Host path': 'C:\\Users\\_username_\\my_python_project'
为'Host path': '/c/Users/_username_/my_python_project'
; About : 关于 :
Why PyCharm ignore File -> Settings -> Build, Execution, Deployment -> Docker -> VirtualBox shared folders
in Run -> Edit Configurations
? 为什么PyCharm会忽略
File -> Settings -> Build, Execution, Deployment -> Docker -> VirtualBox shared folders
Run -> Edit Configurations
File -> Settings -> Build, Execution, Deployment -> Docker -> VirtualBox shared folders
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.