Working directory for non-python kernels in a temp directory
See original GitHub issueBug: Notebook Editor, Interactive Window, Editor cells
Steps to cause the bug to occur
- Create a new jupyter notebook and save it in a file location, or open an existing file
- Change the kernel to something already installed (e.g.
Julia 1.4.2
in my case) - Run
pwd()
to see the working directory
Actual behavior
I am getting C:\\Users\\MYUSERNAME\\AppData\\Local\\Temp\\7bb05f8c-bf2c-4a11-b590-de1cdae0d271
as the path.
This is especially important for Julia since the jupyter kernel activates a Project.toml
and Manifest.toml
local to the path of a file when it starts. This makes reproducible packages/etc. possible, and is difficult to do after startup.
Expected behavior
It should be be where the file is opened or saved. In my case, 'c:\\Users\\MYUSERNAME\\Documents\\GitHub\\sandbox'
This is what happens with python kernels, for example. In that case, ;pwd
returns that string.
Your Jupyter and/or Python environment
- Jupyter server running: Local
- Extension version: 2020.6.91350
- VS Code version: 1.46.1
- Setting python.jediEnabled: false
- Python and/or Anaconda version: 3.7.4 64 bit conda
- OS: Windows
- Virtual environment: conda
Microsoft Data Science for VS Code Engineering Team: @rchiodo, @IanMatthewHuff, @DavidKutu, @DonJayamanne, @greazer, @joyceerhl
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (11 by maintainers)
Top Results From Across the Web
tempfile — Generate temporary files and directories
This module creates temporary files and directories. It works on all supported platforms. TemporaryFile , NamedTemporaryFile , TemporaryDirectory , and ...
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 >Can we make a custom directory in our kernel?
Hi All,. I am working on images data and trying to save the results to the 'preview/' directory as below- os.makedirs('../input/preview').
Read more >Enhance kernels with magic commands - Amazon EMR
EMR Studio and EMR Notebooks support magic commands, which are enhancements provided by the IPython kernel to help run and analyze data.
Read more >How to fix Kernel Error or broken Python in Jupyter Notebook
TL;DW BELOW! If you delete or upgrade your python version, you might get a Kernel Error when trying to use Jupyter Notebooks!
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
Why can’t you set the working directory to that of the notebook before executing the kernel-launch command? That’s what Jupyter does…
Since the change here is in the Python extension then you would actually need the insiders version of our extension (can use that with either normal VS Code or VS Code - insiders). Info is on this here: https://github.com/microsoft/vscode-python/blob/master/CONTRIBUTING.md#development-build It’s very easy to swap that back to the release version, so it’s safe to use that to test if you want.
I believe that this should work with github codespaces, I’ve not tested that myself, but it’s not using anything that would prevent that. However I would assume that github codespaces doesn’t have the insiders version of our extension, so you would not see the fix there yet.