Issue
I'm trying to set current working directory (CWD) to edited file location for Jupyter Notebook in VS Code. I use ${fileDirname}
in python.dataScience.notebookFileRoot
setting. However it uses temporary folder as ${fileDirname}
instead of original file folder.
Same issue was discussed couple times already (e.g. https://stackoverflow.com/a/54794976/12488601) with tried solution pointed out.
Here is example of cwd:
os.getcwd()
.. 'C:\\Users\\MjH\\AppData\\Local\\Temp\\1f6cc207-562f-4ae1-8754-e2013ae2c12d'
While expected result is C:\Workspace\Project.
So use of ${fileDirname}
does not work in my case. I use following ad-hoc solution, which, obviously, won't update if file is moved.
import sys
import os
sys.path.insert(0, r'C:\workspace\project')
os.chdir(sys.path[0])
Now I'm trying to understand three things:
- is my case a unique one?
- if it's general issue, is there a feature request/issue submitted for VS Code to address it?
- is there a better ad-hoc solution?
VS Code version: Code 1.40.2 (f359dd6, 2019-11-25T14:54:45.096Z)
OS version: Windows_NT x64 10.0.17763
Solution
As of January 2021 adding the following line in my setting helps to solve the issue
"jupyter.notebookFileRoot": "${workspaceFolder}",
Answered By - Espoir Murhabazi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.