Jupyter notebook support not finding the correct cwd
See original GitHub issueEnvironment data
- VS Code version: 1.33.1 (Tried with both anaconda installation and debian package installation)
- Extension version: 2019.4.11987
- OS and version: Ubuntu 18.04 LTS
- Python version (& distribution if applicable, e.g. Anaconda): 3.7.3 (Anaconda)
- Type of virtual environment used: conda
Expected behavior
Find the actual path of my python file (/home/theis/code/N_path_intership/PlottingCode/python
)
Actual behavior
Debugger does it correctly after adding "cwd": "${fileDirname}"
to launch.json
, jupyter support doesn’t.
Steps to reproduce:
- Simply run
#%%
import os
print("Hello World!")
print(os.getcwd())
GIF version
Without "cwd": "${fileDirname}"
With "cwd": "${fileDirname}"
Code of my .json
files
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Jupyter notebook support not finding the correct cwd #3422
@notuntoward it seems that you're running from the terminal. The terminal defaults to the workspace directory (hence your cwd being two levels above),...
Read more >How to change working directory in Jupyter Notebook?
From windows start menu open “Anaconda Prompt 1 · Find .jupyter folder file path . In command prompt just type 2 or 3...
Read more >Jupyter Notebook default working directory
Problem is that when running a Jupyter notebook inside of IDEA / PyCharm, the default working directory is the project root.
Read more >How To Change The Working Directory In A Jupyter ...
The OS command – 'chdir' i.e. Change Working Directory will help you change the working directory in the Jupyter notebook and now you...
Read more >[Errno 2] No such file or directory
I've tried creating a shared folder for both the notebook and the CSV but the notebook still can't find the CSV file.
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
I have the same issue.
${fileDirname}
is the default value ofpython.dataScience.notebookFileRoot
but it is completely useless for the remote jupyter server (even if the remote Jupyter server is actually local).I noticed that some
Untitled*.ipynb
were created in the default working directory of the remote jupyter server. So if VSCode is running code in these new notebook files, the working directory will obviously not be correct.However, I have to use a remote Jupyter server because I need to load pyspark and I haven’t found out how to set up a jupyter startup command in VSCode.
I actually have to start jupyter with the following command:
In the end, I chose to first cd to the directory I wanted and then start the remote Jupyter server. This solves the problem, but is not very convenient.
This should be solved when microsoft/vscode-jupyter#827 is fixed