3

我希望能够在 Visual Studio 代码的奇点图像中使用 python 解释器。

似乎将 VSC 指向 python 解释器的所有选项都涉及直接路径,但在图像中使用 python 需要一个命令:

singularity exec path/to/image.img python3.6

我试着把它放在 VSC settings.json 文件中:

    "[python]": {
        "python.pythonPath": "singularity exec /home/sryadgir/all/docker/py_dock/pydock_v0.img python3.6"
    }

没有运气,从 VSC 运行任何 python 代码在这里使用 python 解释器:/usr/bin/python3

4

1 回答 1

4

最简单的方法是使用奇点图像的运行脚本并设置"python.pythonPath": "path/to/python.img"例如,

$ sudo singularity build py36.simg docker://python:3.6 
Docker image path: index.docker.io/library/python:3.6
Cache folder set to /root/.singularity/docker
[9/9] |===================================| 100.0% 
Importing: base Singularity environment
Exploding layer: sha256:6f2f362378c5a6fd915d96d11dda1e0223ccf213bf121ace56ae0f6616ea1dc8.tar.gz
Exploding layer: sha256:494c27a8a6b820f9167ec7e368b3a9bb47d7029f4dc8c97c67091f3757a5bc4e.tar.gz
Exploding layer: sha256:7596bb83081b6c8410df557d538a0ae45922cbf81e469c6f4cfa835247cb24ab.tar.gz
Exploding layer: sha256:372744b62d49eba993652ee4a1201801fe278b687d85489101e07e7b9a4900e0.tar.gz
Exploding layer: sha256:615db220d76c063138a2e6c5849703a7a80d682a682f7e1a841e6e7ed5f43879.tar.gz
Exploding layer: sha256:1865698adfb04b47d1aa53e0f8dac0a511d78285cb4dda39b4f3b0b3b091bb2e.tar.gz
Exploding layer: sha256:7159b3304cc0ff68a7903c2660aa37fdae97a02164449400c6ef283a6aaf3879.tar.gz
Exploding layer: sha256:ad0713808ef687d1e541819f50497506f5dce12604d1af54dbae153d61d5cf21.tar.gz
Exploding layer: sha256:7ba59390457320287875a9c381fee7936b50ecfd21abfe3c50278ac2f39b9786.tar.gz
Exploding layer: sha256:14b2fefd5f8a77dd860f2f455a2108a55836dd0062ced0df5fbd636ce3188ff7.tar.gz
Building Singularity image...
Singularity container built: py36.simg
Cleaning up...

$ ./py36.simg --version
Python 3.6.8
# this is equivalent to:
$ singularity exec py36.simg python3 --version
Python 3.6.8

如果您在多个版本的 python 中使用自定义奇点图像,您可能需要制作一个包装脚本然后使用它。例如,

#!/bin/bash

exec singularity exec python.img python3.6 "$@"
于 2019-06-27T08:59:53.653 回答