How Jupyter extension in VSCODE acess remote Ipynb file when you Jupyter remote server - jupyter-notebook

When you running a Jupyter notebook server on remote, your pc connect remote Jupyter server. You could use remote conda environemnt, remote intepreter.
One thing is different with Notebook(website version), you could not access remote ipynb file.
some many people just create a new blank notebook file and code it on it, but what I need is samething website version of notebook
Did anyone know how to do that?
I try to use SSH(remote devepolyment), it meet so many error and problem, I give up.

Related

problem with kernel creation in vscode while connected to remote jupyter server?

I am trying to connect to remote jupyter server which is running in remote server inside a docker. from vs code (local machine) with the help of jupyter extension, and running a newly created notebook.
The problem seems to be the kernel creation via this method for this newly created notebook.
My Jupyter Server is running in remote server, inside a docker environment, with port forwarding enable.
I can access it via my browser by http://{remote_machine_ip}:{port}/, and I am able to create new jupyter notebook.
However when I use the vs code to open local notebook file, and connect to the remote jupyter server.
When I try to run the cells, it shows the following error:
Failed to start the Kernel.
'_xsrf' argument missing from POST.
View Jupyter log for further details.
Possible solution
However, if I try to open a new kernel in browser, and connect it to same kernel in vs code, the problem goes away.
This issue seems to be arising when vs code sends the request to create jupyter kernel to the jupyter server.
As, when I tested with already running jupyter kernel in vs code, it works fine.
The issue here is, security implementation of jupyter server, which don't allow cross site request to create a kernel, as it security vulnerability.
For more details about _xsrf token, you can read here, although it doesn't talk about specific to jupyter server, its very easy to deduce the logic.
In one post of jetbrains, I found the solution, to make jupyter ignore _xsrf token, by adding new flag while starting the jupyter server,
--NotebookApp.disable_check_xsrf=True
Or add it to your notebook config.
Also, to make sure your request are not been blocked, as suggested by vscode blog. Add the following flag too,
--NotebookApp.allow_origin='*'

jupyter notebook can't be saved from the remote access

I run a jupyter notebook which can access from the remote IP on our lab server(Of course I visited from the intranet of the school). And everything seems ok.
However, when I create a test.ipynb from the remote IP and write sth and save finally, nothing happens but autosave failed.
But the question is I can access the jupyter server from the lab server via localhost like.
And the save operation work!
I don't know why this happens??
I've tried to use chomd to add permissions, but it doesn't work.
And I've tried to use a docker to provide jupyter server, but it doesn't work either.
It seems to encounter some network problems that I never meet before.
Is that sth wrong with the lab server?

Access to Jupyter notebook from outside - How to allow google colab to access a local host Jupyter notebook?

I am trying to connect from google colab to local host - it does not work,
google troubleshooting advise suggests that I should allow local Jupyter notebook to accept colab requests - how to do it ?
Screenshot from local host which confirms that requests from colab are forbidden.
There should be some config modification to allow such requests, is not it ?
Advise from colab:
How I fixed my connection issues:
If after the above commands don't work, what finally did it for me was creating a firewall rule for port 8888.
Another big one that is in the instructions in your command line but not stated on the provided Google tutorial that some people will miss is that you need to open the URL in your browser that's given to you after launching Jupyter in order for it to create the access cookie and make it valid (sort of speak).
From the screenshot you provided, make sure you have "http://localhost:8888/?token=2534..." opened in your browser that is logged in with the same account accessing colab before it will allow access to colab (a separate window or tab will usually pops up on it's own when you run the command though).
Alternatively, you can also add the --no-browser tag to prevent the need to open it in your browser
Other solutions that involve installation issues to mitigate network issues:
There were a number of other troubleshooting steps that were particular to me but dont know if will apply to you but did you have any issues when installing Jupyter?
For me, even though jupyter would still launch, there were errors when installing on Windows, and to fix those I had to replace pip with pipwin and go through the steps that way.
For example
pipwin install jupyterlabs
pipwin install jupyter_http_over_ws
And in case it helps anyone else coming across this in the future, if you're using the DOS cmd line and have issues launching jupyter, replace the "" with a "^" to indicate continuation
i.e.:
jupyter notebook --NotebookApp.allow_origin="https://colab.research.google.com" --port=8888 --NotebookApp.port_retries=0

Connecting Google Colaboratory Notebook to the local system (which is a remote system to my system)

I want to connect to my local system in Google Colaboratory notebook, and I have redirected to this page as there explained the instructions for doing such a thing. However, the local system that I've been always working with and am trying to connect my Google Colaboratory notebook to it is actually a remote Linux-based machine.
Before when I wanted to start Jupyter notebook on my remote machine I ran this command on the remote machine that I was connected to through ssh:
$ jupyter notebook --no-browser --port=8889
Then in my own machine, I ran this command to work with the jupyter:
$ ssh -N -L localhost:8888:localhost:8889 [username]#[remote_address]
However, now that the situation is different, even though I followed the given instructions in the link I still cannot connect Google Colaboratory notebook to the remote machine.
I tried to apply the usual procedure I do for tunneling to the remote machine, i.e I changed the port number to 8889 and ran that tunneling command in my system and in my Colab notebook which was opened with the browser in my system (not the remote) I entered the URL I was given as a token. I once changed 8889 in the URL to 8888 (something I had always been doing for opening running jupyter notebook on the remote machine, in my system), and another time I didn't change the port number. But, neither one worked.
I was wondering if anyone here knows what is the way for doing such a thing. I would greatly appreciate the help.
Thanks!

Locking an IPython notebook for editing

I have IPython notebooks running on a server, and I'm editing/prototyping them locally. I use rsync to push my local notebooks when I'm ready to show them to others.
Problem is, with all these notebooks open, it's easy to accidentally edit things on the server notebooks instead of the local ones. Is there some reasonable mechanism to prevent accidental editing of notebooks? I still want to be able to run the server-notebooks, and they still should be able to write output - I just want to somehow lock them so they can't be edited.
You can also just change the notebook permissions to be read-only by opening a new Terminal directly in your Jupyter server.

Resources