Home  >  Article  >  Development Tools  >  What should I do if vscode cannot find the path?

What should I do if vscode cannot find the path?

藏色散人
藏色散人Original
2020-04-02 09:08:079592browse

What should I do if vscode cannot find the path?

#What should I do if vscode cannot find the path?

Solution to the problem that the VS code file reference cannot find the path

Recommended learning: vscode tutorial

VScode is indexed according to the path of the .vscode folder in the root directory of the workspace as an absolute path. If there are many folders in the workspace and the py file in the folder needs to reference the file in the current directory, follow the usual The file cannot be found when writing a relative path. In this case, you need to add "cwd": "${fileDirname}" to the launch.json file in the .vscode folder and the debugging environment used to specify where to debug. Find the file, ${fileDirname} represents the absolute path of the currently opened file, excluding the file name, so that after setting, the normal relative path can be used to introduce the file in the py file.

Example:

{
"name": "当前文件 (外部终端)",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"console": "externalTerminal"
 }

The above is the detailed content of What should I do if vscode cannot find the path?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn