Wrong current working directory when running python code and jupyter extension in vscode

后端 未结 2 1870
春和景丽
春和景丽 2021-01-03 02:30

I am trying to run python code using the jupyter extension in vscode here

I have a workspace open at this location /Users/user/Documents/ When I try and run the fol

2条回答
  •  一整个雨季
    2021-01-03 03:03

    For any specific folder / workspace that you have open in VS Code you can use the notebookFileRoot setting to set a specific absolute path directory to always set the Jupyter working directory to when you start the Interactive Window with that folder open.

    Always opening on the file location (without having to set notebookFileRoot to an absolute path per folder) is not supported via the notebookFileRoot setting. The VSCode variables such as ${fileDirname} are specific to task and debug configuration files (launch.json and task.json). We've specifically added code to recognize ${workspaceFolder} for our settings page but we don't recognize other VSCode variables in there.

    If you want there is a github item here that has suggested this feature. You can follow that or vote it up if you want this feature added. https://github.com/Microsoft/vscode-python/issues/4441

    Edit 11/5/2019: We have now made a change to allow the VS Code "Notebook File Root" setting to be set to ${fileDirname}. This setting will now start up Notebook Editor and Interactive Window session relative to the file location that was used to start them.

提交回复
热议问题