Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99157

Current working directory for jupyter notebook sets to temp folder in vscode

$
0
0

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:

  1. is my case a unique one?
  2. if it's general issue, is there a feature request/issue submitted for VS Code to address it?
  3. 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


Viewing all articles
Browse latest Browse all 99157

Trending Articles