Jupyter Lab shows last used folder as the root directory when run from terminal (can't go up), but it's ok when run from Anaconda - terminal

I've been using Anaconda and Jupyter Lab & Notebook for a couple of months. I have 4 environments and had the usual problems I guess everyone has with package conflicts and such.
Today, when I was running a ipynb file in Jupyter Lab (run from Terminal), it got stuck when iterating over files and unzipping them, so I rebooted my Mac.
When I entered Jupyter Lab again, the folder it showed in the file browser was the last one I had used. It didn't have the option of going up, and if I entered a path in "open from path", it said that it couldn't find it. It's like the last folder I used is now considered the root path.
I tried running Jupyter Lab again from terminal, but same thing.
Of course, other environments weren't affected.
I thought it was a Jupyter Lab configuration problem, but when I run Jupyter Lab from Anaconda, it went back to working perfectly, so I'm wondering if there is a configuration setup specifically for Terminal.
I can work from Anaconda, and I can also reinstall the environment if needed, but I'd prefer to go back working the way I was.
Jupyter Notebook works fine.
Can anyone shed a light on what can be happening?
Thanks!
I tried:
reboot the computer
exit and reenter Jupyter Lab
go to "open from path"
search for jupyter config file with "jupyter --config-dir". Found "default-37a8.jupyterlab-workspace" in the /User/.jupyer/lab/workspaces folder, and it has the initial config for Jupyter Lab (directory, files opened), but it takes the info from when I close the instance I run from Anaconda. When run from terminal it's like it takes the initial config from somewhere else.

Related

Does jupyter lab work within its own conda environment it was installed in?

I have multiple conda environments on my PC created with Anaconda and I have installed jupyterlab in two of them. I used one environment for R programming and the other for Tensorflow with Python. I have noticed that whenever I open jupyter lab in either of the environments, it always starts off where I left it. That is, the last open notebooks are opened on start. Of course, this doesn't bother me too much, but it makes me think each jupyter lab installation isn't contained within its own environment.
For example, I have two environments. Say they're called env_R and env_Python_TF. I have installed jupyter lab in both environments.
I open Anaconda Powershell prompt and launch each environment using the following commands:
(base) PS $ conda activate env_R
(env_R)PS $ jupyter lab
Say I work on jupyter lab and once I'm done, I close the browser windows and then shut down the server using CTRL+C in Anaconda Powershell prompt. Now if I open up my second environment using:
(base) PS $ conda activate env_Python_TF
(env_Python_TF)PS $ jupyter lab
Now I see the same notebooks I used with env_R opened up when jupyter lab opens in my browser.
Aren't each jupyter lab installation contained within its own conda environments? If not, have I possibly made a mistake in my configuration?
it should be within its own conda environment but Default root folder /location will remain same for jupyter notebook. You will need to change it using config file.
Here is link

Can't open Jupyter notebook from command prompt

I have always opened the jupyter notebooks from the Anaconda prompt. The problem is that whenever I try to open the Jupyter notebook from the command prompt, the following error is displayed:
Picture of the Error shown on my command prompt window
ImportError: DLL load failed: The specified module could not be found.
What am I doing wrong ? What should I do?
Opening Jupyter Notebook from command prompt is useful, especially when you would like to open the Jupyter Notebook from a specific folder.
The following 2 steps might help you to resolve this issue.
open command prompt
activate base
The prompt might change to begin with "(base)", which is expected. Then type,
Jupyter-notebook
If Jupyter notebook opens up now, this means Jupyter is correctly installed within your conda environment. In OS like Windows 10, it was an expected behavior not to recognize Python outside of Conda environment, which extends to Jupyter Notebook as well.
If the 1st step works properly, then add the below paths to your
environment variable. If you would not like to add the path to your
system environment variable, you can choose to update in your
account environment variable.
In windows 10 >> search "environments" and "Edit environment
variables for your account"
Select "PATH" and edit.
Add below paths
C:\Users\\Anaconda3;
C:\Users\\Anaconda3\Scripts;
C:\Users\\Anaconda3\Lib;
C:\Users\\Anaconda3\Library\bin;
C:\Users\\Anaconda3\Library\mingw-w64\bin;
Now you should be able to open Jupyter Notebook directly from command prompt.

Jupyter Notebook Won't Open in Newly Installed Firefox Quantum

I installed the newest Firefox version (Quantum v. 65) on an Ubuntu machine and Jupyter Notebook will not open in it from either Anaconda or a command prompt.
I received the following error:
"Access to the file was denied
The file at /run/user/1000/jupyter/nbserver-11292-open.html is not readable.
It may have been removed, moved, or file permissions may be preventing access."
Any ideas on how to fix this would be greatly appreciated.
I'm having the same issue with Firefox snap.
Luckily, jupyter notebook, when run from the command line, also outputs a link that you can copy and paste on the browser (or just Ctr + click).
To access the notebook, open this file in a browser:
file:///run/user/1001/jupyter/nbserver-30315-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=a0602687337c0045f9dc2106a5a7fb466a9a86dd74378f64
Not an optimal solution but an acceptable work-around.

Changing Jupyter Notebook start up folder by modifying "start in" not working any more

I used to be able to change the default start up folder for Jupyter (the folder Jupyter displays in browser when it was first started) by modifying the "start in" option of the Notebook launch icon's properties on Windows, as described here and here.
However, this is not working any more after I recently installed Anaconda 3. Even though I changed the "start in" folder to the folder I wish, the browser still goes to "Documents" folder by default. I tried doing this as admin, still didn't work. Any suggestions? Thanks!
Although a permanent fix is still not found, I do have the following workaround that works great!
Using the way described here, change the start up dir for Anaconda prompt, then launch it and make sure the default folder is the one you want, and type "jupyter notebook". There! The notebook should launch in your desired folder.
UPDATE:
You can also directly launch Anaconda Prompt, then use cd C:\Users\Name\Folder to navigate into the folder where your iPython notebook files are located, and then use jupyter notebook or jupyter notebook myfile.ipynb to start working!
The only thing that worked for me to permanently fix the default working directory is by using this comment by MrFancypants.
In your default directory (documents), there is a hidden folder /.jupyter and within it a config python file.
you can edit it and change the line
## The directory to use for notebooks and kernels.
#c.NotebookApp.notebook_dir = ''
to
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'ENTER_PATH_HERE'
where you should put your favorite path instead of 'ENTER_PATH_HERE.

Is it possible to navigate to a parent directory in the jupyter tree?

Normally, I launch jupyter from a new bash terminal:
~$ jupyter notebook
and then navigate down the tree to the files I want to work at.
I just did it from a terminal that was already running at a different path:
~/blah/blah/blah$ jupyter notebook
and realized that that directory becomes the home for jupyter. I wanted to work at a file located at, say ~/blah/thingy/luis.ipynb, but couldn't find my way up.
How do I navigate the directory tree upwards in jupyter notebook?
As explained in https://github.com/ipython/ipython/issues/7751, it is not possible to navigate to the parent directory for security reasons:
The kernel might not be python, nor on the same machine than the
server, nor do you need a running kernel to use server API(s).
If you want, you can ask for more information in the aforementioned GitHub issue.
As edwinksl pointed out it is not possible for security reasons. See https://github.com/jupyter/notebook/issues/2032.
But if you want to keep your luis.ipynb file in its original location and still be able to access it from Jupyter Notebook browser, you can create a symlink to it in your running Jupyter Notebook directory:
ln -s ~/blah/thingy/luis.ipynb ~/blah/blah/blah/
For more details on symlinks see https://www.howtogeek.com/297721/how-to-create-and-use-symbolic-links-aka-symlinks-on-a-mac/

Resources