`python.dataScience.notebookFileRoot` needs an option to launch with CWD = current file path
See original GitHub issueEnvironment data
- VS Code version: 1.31
- Extension version (available under the Extensions sidebar): 2019.1.0
- OS and version: Debian Stretch
- Python version (& distribution if applicable, e.g. Anaconda): 3.5.3
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
- Relevant/affected Python packages and their versions: N/A
Expected behaviour
Having a Python script with cell markers #%%
, I’d expect that setting python.dataScience.notebookFileRoot = ${fileDirname}
makes the interactive session start in the directory the file resides.
Maybe I misunderstand that setting? At least, it is what calculateWorkingDirectory
is supposed to do, isn’t it?
Also see this Stack Overflow question
Actual behaviour
The interactive session starts from the workspace directory.
Steps to reproduce:
Having a structure like this
workingDir
|- foo
|- file.py
and a file.py
:
#%%
import os
print(os.getcwd())
the output in the interactive session is the absolute path of the workingDir
.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:17
- Comments:18 (7 by maintainers)
Top Results From Across the Web
`python.dataScience.notebookFileRoot` needs an option to ...
python.dataScience.notebookFileRoot needs an option to launch with CWD = current file path #3605.
Read more >Current working directory for jupyter notebook sets to temp ...
I use ${fileDirname} in python.dataScience.notebookFileRoot setting. However it uses temporary folder as ${fileDirname} instead of original file ...
Read more >[FIXED] Current working directory for jupyter notebook sets to ...
I'm trying to set current working directory (CWD) to edited file location for Jupyter Notebook in VS Code. I use ${fileDirname} in python....
Read more >Current Working Directory - Programming Python, Second ...
When you run a Python script by typing a shell command line like python dir1\dir2\file.py , the CWD is the directory you were...
Read more >How to Get the Full Path of the Current File Directory in Python?
Method 1: pathlib.cwd(). To get your current path in Python, use the pathlib module in the python standard library and call cwd() that's ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes please. When working interactively, I always want the kernel to start in the directory of the file I’m executing. If it is starting elsewhere it will mess up my imports unless I add file’s directory to PATH manually…
deleting the contents in this block seems to work for me (inside a workspace folder)