Current Working Directory

31 views
Skip to first unread message

Javi Alfaro

unread,
Jan 28, 2020, 5:02:03 PM1/28/20
to Project Jupyter
Good evening from El Salvador,

I apologize if my query shouldn't be posted here. 

I understand that when running Jupyter notebooks, the default working directory is the directory the notebook is open in, but I'm not sure what happened and this doesn't happen anymore, my current working directory has been set, accidentally, to a different path. How can I correct this to the default option?

Thanks in advance,

Javier Alfaro.

Jason Grout

unread,
Jan 28, 2020, 5:49:32 PM1/28/20
to Project Jupyter
You can change that default directory in the notebook configuration, or from the comand line with: jupyter notebook --NotebookApp.notebook_dir='/path/to/directory'.

Perhaps you need to look at your config file. You can find the config file in one of the config directories listed by `jupyter --paths`. Look for the jupyter_notebook_config.py file.

Here are instructions for setting that config value, which may help narrow down things: https://stackoverflow.com/a/40514875

Thanks,

Jason


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/70f17237-6aa0-4ff6-9fca-f4a90972304a%40googlegroups.com.

Javi Alfaro

unread,
Jan 28, 2020, 11:45:28 PM1/28/20
to jup...@googlegroups.com
Hi Jason,

Thank you very much for your response. I tried everything, but for some reason the problem still persists. 

The only code that gave me the real working folder path was :

globals()['_dh'][0]


But I wasn't able to make the ipynb file to load the current folder path :( ... I also tried uninstalling and installing jupyter again.

Jason Grout

unread,
Jan 29, 2020, 12:16:05 AM1/29/20
to Project Jupyter
Ah, I think I misunderstood your question. I thought you were talking about the default folder path for the notebook server, but it seems instead you are talking about the current working directory of your kernel process?

Can you give us more information? What path is your notebook in and what is your kernel current working directory, and how might those two paths be related? Have you reproduced this in a clean environment? What versions of software are you running?

Thanks,

Jason



Javi Alfaro

unread,
Jan 29, 2020, 12:51:33 AM1/29/20
to jup...@googlegroups.com
My bad, maybe I wasn't clear the first time. I am indeed talking about the cwd of my kernel process.

When I run jupyter from the command line and I open an ipynb file, the cwd of the kernel process will always default to a one different from where it was opened.

E.g. 

'C:\\Users\\XXX\\Dropbox\\esen_ra\\data\\interim\\ja'

That's what I get from running the command "pwd" everytime I open a new ipynb file. So I have to (always) write os.chdir(globals()['_dh'][0]) in order to get:

'C:\\Users\\XXX\\Dropbox\\Master\\ESEN\\Ayudantías\\Python'

Which is the correct path where I opened the file. I'm not sure if this helps, but if I run jupyter from Anaconda Navigator, I do not have this problem. 

I apologize if I'm making things more confusing than they actually are.

Software versions:

jupyter: 1.0.0
jupyter-client: 5.3.4
jupyter-console: 6.1.0
jupyter-contrib-core: 0.3.3
jupyter-contrib-nbextensions: 0.5.1
jupyter-core: 4.6.1
jupyter-highlight-selected-word: 0.2.0
jupyter-latex-envs: 1.4.6
jupyter-nbextensions-configurator: 0.4.1
jupyterthemes: 0.20.0

Thanks in advance,

JA.

Jason Grout

unread,
Jan 29, 2020, 8:46:52 AM1/29/20
to Project Jupyter
And what is your notebook package and any packages that start with "ipy" (ipykernel, ipython, etc.)?

Jason Grout

unread,
Jan 29, 2020, 8:51:47 AM1/29/20
to Project Jupyter
More questions to help understand your situation better:

And are there any errors in the notebook log (printed to the terminal where you launched the notebook)?
Do you see any Javascript errors in the browser debugger console?
Are you using JupyterLab (if so, what version of that too)?
Can you give us the command you use to invoke the notebook?
Can you give us the config file for the notebook (and if using JupyterLab, its config file too)? (see the path given by "jupyter --config-dir")
What happens if you create a fresh new conda environment and launch that notebook?

Thanks,

Jason

 
Reply all
Reply to author
Forward
0 new messages