spyder-ide / spyder-notebook

Jupyter notebook integration with Spyder
Other
532 stars 130 forks source link

Cannot open a notebook from specific directory in WSL #263

Open MuriloHMoreira opened 4 years ago

MuriloHMoreira commented 4 years ago

Description of your problem

Cannot open a notebook from a directory different from /tmp/scipy-user/notebooks. When tried, it yelds a Fail page, "404: Not found", and a warning in the cmd noting that such file does not exist

What steps will reproduce the problem?

  1. Install conda on Ubuntu 18.04 on Windows Linux Subsystem
  2. Install spyder-notebook from conda
  3. Run xming to have the GUI on Windows 10
  4. Try to open a notebook that is in a different directory from (regardless of the notebook being on the Windows 10, or any directory of the Ubuntu subsytem).

What is the expected output? What do you see instead? The expected output was to be able to open notebooks from different directories. With the current instalation, I can only use on the notebooks located in the /tmp/scipy-user/notebooks/ directory.

Please provide any additional information below (stack trace, screenshots, a gif, etc)

Versions and main components

Thank you very much, Murilo

jitseniesen commented 4 years ago

Hi Murilo. Thank you for your report. As far as I know, it works on both Ubuntu and Windows, regardless of the directory the notebook is stored in. So I guess it is something specific to the Windows Linux Subsystem, which is not a configuration that we test on.

a warning in the cmd noting that such file does not exist

Can you please be a bit more specific. What exactly is the warning? What do you mean with "cmd"?

It may be helpful to start Spyder from the command line as spyder --debug-info verbose. If we are lucky, it will print some more information if you open a notebook from a "wrong" directory.

MuriloHMoreira commented 4 years ago

Hi Jitse! Thank you for the fast answer! Yes, I guessed such a configuration was not very common, I had to follow this route as I need to work with a library that is not implemented in Windows. Sorry about my bad description! I mean terminal by 'cmd', sorry! The warning is: [W 07:53:26.797 NotebookApp] 404 GET /notebooks/Untitled.ipynb?token=0b27cb4eb6e70071682d5f7a5d571532415e65623697b3cb (127.0.0.1): No such file or directory: Untitled.ipynb [W 07:53:26.802 NotebookApp] 404 GET /notebooks/Untitled.ipynb?token=0b27cb4eb6e70071682d5f7a5d571532415e65623697b3cb (127.0.0.1) 6.36ms referer=None After I run the spyder command in the terminal, it shows a warning saying: [I 07:53:04.490 NotebookApp] Serving notebooks from local directory: /tmp/spyder-user/notebooks

I am trying to investigate how could I change this directory. Thank you very much! All the best, Murilo

MuriloHMoreira commented 4 years ago

Oh! Another important information that I was forgetting to give. When I close the window with the fail error (which should be the jupyter notebook) I get this warning: image

MuriloHMoreira commented 4 years ago

Another info: I disable the token authentication on Jupyter. Now, when I try to close the 404: Not Found window the previous message doesn't show. And more, I list the notebooks with jupyter notebook list and it shows: Currently running servers: http://localhost:8888/ :: /home/user http://localhost:8888/ :: /tmp/spyder-user/notebooks http://localhost:8888/ :: /mnt/c/Users/murilo/fenics

However, it still yields the 404. I will continue investigating! Thanks, Murilo

MuriloHMoreira commented 4 years ago

Hi Jitse! Thank you for the fast answer! Yes, I guessed such a configuration was not very common, I had to follow this route as I need to work with a library that is not implemented in Windows. Sorry about my bad description! I mean terminal by 'cmd', sorry! The warning is: [W 07:53:26.797 NotebookApp] 404 GET /notebooks/Untitled.ipynb?token=0b27cb4eb6e70071682d5f7a5d571532415e65623697b3cb (127.0.0.1): No such file or directory: Untitled.ipynb [W 07:53:26.802 NotebookApp] 404 GET /notebooks/Untitled.ipynb?token=0b27cb4eb6e70071682d5f7a5d571532415e65623697b3cb (127.0.0.1) 6.36ms referer=None After I run the spyder command in the terminal, it shows a warning saying: [I 07:53:04.490 NotebookApp] Serving notebooks from local directory: /tmp/spyder-user/notebooks

I am trying to investigate how could I change this directory. Thank you very much! All the best, Murilo

Just another point that I just noticed now: I tried to open the Untitled.ipynb from /home/user/Untitled.ipynb, however notice that the 404 GET error states: /notebooks/Untitled.ipynb

Thanks, Murilo

jitseniesen commented 4 years ago

After I run the spyder command in the terminal, it shows a warning saying: [I 07:53:04.490 NotebookApp] Serving notebooks from local directory: /tmp/spyder-user/notebooks

I am trying to investigate how could I change this directory.

This is as intended. When you start Spyder, it spins up a notebook server which serves notebooks from a temporary directory. If you then open a notebook in a different directory, Spyder will stat another notebook server for that directory. At that point, you should get messages like

Starting new server
[I 10:00:04.841 NotebookApp] The port 8888 is already in use, trying another port.
[I 10:00:04.844 NotebookApp] Serving notebooks from local directory: /home/jitse

The location of the temporary directory is set here: https://github.com/spyder-ide/spyder-notebook/blob/adc080aea93f7fff23d6519940f433662ef81d9d/spyder_notebook/notebookplugin.py#L40 However, be careful if you change it. Notebooks in the temporary directory are treated differently. For example, they are deleted if you close them: https://github.com/spyder-ide/spyder-notebook/blob/adc080aea93f7fff23d6519940f433662ef81d9d/spyder_notebook/notebookplugin.py#L381-L387

When I close the window with the fail error (which should be the jupyter notebook) I get this warning:

The "Forbidden" message suggests that there is something like a firewall which blocks communication between Spyder and the notebook server. Try (temporarily) turning off your Windows or Ubuntu firewalls and see whether that helps.

And more, I list the notebooks with jupyter notebook list and it shows: Currently running servers: http://localhost:8888/ :: /home/user http://localhost:8888/ :: /tmp/spyder-user/notebooks http://localhost:8888/ :: /mnt/c/Users/murilo/fenics

This is weird. It looks like Spyder started up new servers for all the directories that you tried to open notebooks from, but they all use port 8888. Normally, Jupyter is smart enough to notice that port 8888 is already in use and it will use different ports for other servers, as indicated by the message "The port 8888 is already in use, trying another port."

It seems that somebody else noticed this problem: https://stackoverflow.com/questions/50882266/using-jupyter-with-windows-subsystem-for-linux#50882370

Maybe you can work around it by commenting out the line: https://github.com/spyder-ide/spyder-notebook/blob/adc080aea93f7fff23d6519940f433662ef81d9d/spyder_notebook/notebookplugin.py#L185

I think that is the line which opens a temporary notebook when you start Spyder, and thus start up a Jupyter notebook server in the temporary notebook directory. Hopefully, if you delete the line, the first notebook server points at the directory that you want and will work. However, you probably won't be able to open notebooks in a different directory.

I tried to open the Untitled.ipynb from /home/user/Untitled.ipynb, however notice that the 404 GET error states: /notebooks/Untitled.ipynb

This is normal.

MuriloHMoreira commented 4 years ago

Hi! After I commented line 185, the plugin simply disappeared. However, before doing so, I changed the directory and it was working fine! So as long as taking some precautions I think I will be able to use it! Thank you very much for your help! All the best, Murilo