简体   繁体   English

如何在 VS 代码中配置 launch.json 以在 Windows 中接受网络路径(python)

[英]how to configure the launch.json in VS code to accept a network path (python) in windows

I have been given the following network path to a python exe (in windows10 ):我已获得python exe 的以下网络路径(在windows10中):

\\eu\tac\conda\1.0\win\envs\dev\CURRENT\python.exe

Note the single and double \ 's in the above path.请注意上述路径中的单引号和双\

i try to edit the launch.json in vscode to include this as follows:我尝试在vscode launch.json包含以下内容:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true
        },
        {
            "name": "Python: network (not working)",
            "type": "python",
            "request": "launch",
            "program": "\\eu\\tac\\conda\\1.0\\win\\envs\\dev\\CURRENT\\python.exe",
            "console": "integratedTerminal",
            "justMyCode": true

        }
    ]
}

However, i keep getting errors either referring to invalid syntax which presumably come from the \ and / variants that i have tried.但是,我不断收到错误,或者是指无效语法,这些语法可能来自我尝试过的\/变体。 Or a No such file or directory: 'H:\\eu\\tac\\conda\\1.0\\win\\envs\\dev\\CURRENT\\python.exe' error message as the terminal adds an H: prior to the program.No such file or directory: 'H:\\eu\\tac\\conda\\1.0\\win\\envs\\dev\\CURRENT\\python.exe'错误消息,因为终端添加了H:在节目之前。

So the question is, how can i get vscode to recognise the path correctly ?所以问题是,我怎样才能让vscode正确识别路径?

So what i have discovered is that the "program": "${file}" in the launch.json actually refers to the file to be run and not the executable file path.所以我发现launch.json中的"program": "${file}"实际上是指要运行的文件而不是可执行文件路径。

Selecting the python executable file is done from the settings under default interpreter path and conda path (for conda).default interpreter pathconda path (用于 conda)下的设置中选择 python 可执行文件。

by changing both of the above parameters to the exe file name (in this case) \\eu\tac\conda\1.0\win\envs\dev\CURRENT\python.exe seemed to point vscode to the correct python exe.通过将上述两个参数更改为 exe 文件名(在这种情况下) \\eu\tac\conda\1.0\win\envs\dev\CURRENT\python.exe似乎将vscode指向正确的 python exe。

For clarity, is a picture of where and how:为清楚起见,是一张关于地点和方式的图片: 在此处输入图像描述

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

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