在Visual Studio代码中使用奇异容器作为Python解释器
我通过VSCODE远程SSH连接到HPC环境,并希望直接在VSCODE中运行Python代码以进行测试。我想将Python解释器设置为一个奇异的容器,该容器在执行后运行Python。这是通过在容器的.def文件中添加以下行来完成的:
%runscript
exec python
手动执行容器确实按预期启动Python会话。但是,将Python解释器的路径设置为VSCODE中的容器文件时,什么都不会发生。它不断要求解释器的路径,好像没有收到任何输入。我试图在VSCODE GUI中设置路径,并通过设置JSON设置文件中的默认路径这样:
{
"python.defaultInterpreterPath":"~/path/to/singularity.sif"
}
尽管此方法在这里成功地报告了: Python代码完成Intellion Intellion Intellion Intellion Intellisense使用Singularity Contulity Containser Interner Interner ; 在那里: 如何?我在Visual Studio代码中使用奇异性/Docker图像中使用Python解释器。
但是,我可以选择不包含在奇点容器中的口译器,并且效果很好。值得注意的是,如果我将奇点容器作为沙盒构建,并为沙盒中的Python垃圾箱提供了路径。
知道这里有什么问题吗?我将最新版本的VSCODE(v1.68.1)与Ubuntu 22.04上的遥控器-SSH扩展(v0.82.1)和Python扩展(v2022.8.0)一起使用;用(v3.5.3)创建了奇异图像。
I am connecting to an HPC environment through VScode remote ssh and would like to run python code directly in VScode for testing purposes. I would like to set the python interpreter to a singularity container which runs python upon execution. This was done by adding the following lines in the .def file of the container:
%runscript
exec python
Executing the container manually does start a python session as intended. However, nothing happens when setting the path of the python interpreter to the container file in VScode. It keeps asking for the path of the interpreter as if it did not receive any input. I tried to set the path both in VScode GUI and by setting the default path in the JSON settings file like so:
{
"python.defaultInterpreterPath":"~/path/to/singularity.sif"
}
Although this approach was reported successful here:
Python code completion IntelliSense using Singularity container interpreter ;
and there:
How can I use a python interpreter in a singularity/docker image in visual studio code .
I can however select interpreters that are not contained in singularity containers and it works fine. Notably, it works if I build the singularity container as a sandbox and provide a path to the python's bin in the sandbox.
Any idea what could go wrong here? I am using the latest version of VScode (v1.68.1) with the the Remote - SSH extension (v0.82.1) and Python extension (v2022.8.0) on Ubuntu 22.04; singularity images were created with (v3.5.3).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我一直在尝试解决同一问题,但找到了另一种解决方案。
因此,您实际上可以在主机上运行vscode Server 主机上的奇异容器,而不是在主机上运行VSCODE服务器。从此评论 Oschulz github用户。
放入vscode的
settings.json 中的 true 中的“ remote.ssh.ssh.ssh.ssh.ssh.ssh.ssh.ssh.ssh.ssh.ssh.ssh.ssh.ssh.json
ssh myimage1〜Some -Host
以及类似python3 -version
之类的东西,settings.json.json
:myimage1〜some -Host
。您可能需要
在主机上杀死VS代码服务器...
如果某些内容不起作用。只需在Vscode的命令Palete中键入“ Kill”。I have been trying to solve the same issue but found an alternative solution.
So instead of running vscode server on the host, you can actually run vscode server inside the singularity container on the host. The following procedure is cut from this comment by @oschulz github user.
"remote.SSH.enableRemoteCommand": true
in your vscode'ssettings.json
$HOME/.ssh/config
ssh myimage1~somehost
and something likepython3 --version
settings.json
:myimage1~somehost
.You might want to
Kill VS Code Server On Host...
if something is not working. Just type "kill" in vscode's command palete.