我正在尝试使用Visual Code打开python项目,但是在导入文件“找不到文件”时出现错误。在Pycharm中,可以编辑项目结构并将文件添加为“源”。在Vscode中怎么可能?
我已尝试在文件>将文件夹添加到工作区中将文件夹添加到工作区。
我没有任何代码可用于此目的。该项目可以在Pycharm中正常运行,但可以在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",
"cwd": "${workspaceFolder}",
"env": {
"PYTHONPATH": "${workspaceFolder}\\folder1;
${workspaceFolder}\\folder2\\dada;
${workspaceFolder}\\folder3\\dadadsada "
}
}
]}
现在我只需要去调试>运行而不进行调试,就可以了。