"Unable to connect to the local runtime" in google colab - jupyter-notebook

I'm trying to connect local run time but it's not connecting,
I used the troubleshooting dialog following commands:
pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws
jupyter notebook \ --NotebookApp.allow_origin='https://colab.research.google.com --port=8888 \--NotebookApp.port_retries=0
Have tried the same above steps as said in below URL
https://research.google.com/colaboratory/local-runtimes.html
Facing an issue 'Jupyter authentication cookie was not detected'
Tried by disabling adblocker, antivirus and also using different port numbers. Below was the solution given by team
Navigate to http://localhost:8888 in a separate browser tab and follow the provided instructions. This will set a browser cookie used for authentication between the browser and the Jupyter notebook server.
But when I open the URL, it asks for a password(already set up) and then no further instructions are appearing.

This issue was raised in Github issues for Collaboratory:
This answer helped me https://github.com/googlecolab/jupyter_http_over_ws/issues/1#issuecomment-557469128
According to this issue
start the jupyter notebook with the below command.
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --NotebookApp.port_retries=0 --notebook-dir="" --no-browser --allow-root --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True --port=8888
then open the notebook by going to this URL.
localhost:8888
according to kris This may allow you to connect, but it basically disables all security features.
Then retry connecting to local runtime with Google Colab
If it does not solve your problem then try disabling AdBlock extension or app.

For Windows (10/11)
Method 1: Using git bash
follow these steps
https://research.google.com/colaboratory/local-runtimes.html
Method 2: Using Windows terminal & Multiline commands
Install jupyter_http_over_ws
pip install jupyter_http_over_ws
enable the jupyter_http_over_ws jupyter extension (one-time)
jupyter serverextension enable --py jupyter_http_over_ws
Use multiline commands to start server and authenticate
jupyter notebook ^
--NotebookApp.allow_origin='https://colab.research.google.com' ^
--port=8888 ^
--NotebookApp.port_retries=0
Method 3: Using single-line command & windows terminal
Install jupyter_http_over_ws
pip install jupyter_http_over_ws
enable the jupyter_http_over_ws jupyter extension (one-time)
jupyter serverextension enable --py jupyter_http_over_ws
Use single-line commands to start server and authenticate
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888 --NotebookApp.port_retries=0
Once the server has started, it will print a message with the initial backend URL used for authentication. Make a copy of this URL as you'll need to provide this in the next step.
Connect to the local runtime
In Colaboratory, click the "Connect" button and select "Connect to local runtime...". Enter the URL from the previous step in the dialog that appears and click the "Connect" button. After this, you should now be connected to your local runtime.

There are several reasons why a local connection might fail. To gather more diagnosis information, click the 'troubleshoot' link in the notification that appears in the lower left of the screen.
It will look like this:
I'd recommend following whatever steps are recommended there. If you get stuck, please update your original question with the diagnosis offered in the troubleshooting dialog.

Related

prevent jupyterlab from automatically starting new session for all open tabs

I shut down all kernels and close jupyterlab in the browser, but when I open it again it starts a session, and a kernel, for all opened notebooks
I'd followed the code and found that in jupyterlab notebook code the start session function calls (POST /api/sessions) on notebook load if there is not any running kernel for the current notebook. and the API creates a session and also starts a kernel.
I can't find any config for stopping this action in jupyter configs or jupyterlab settings (settings -> advanced settings editor)
You can prevent automatically starting kernels when you open a notebook by running Jupyterlab with the jupyter lab --LabServerApp.notebook_starts_kernel=False flag.
To make the configuration permanent, you can add
c.LabServerApp.notebook_starts_kernel = False to $(jupyter --config-dir)/jupyter_lab_config.py. If this file doesn't exist yet, generate it by running jupyter lab --generate-config.
See this issue comment for more details:
https://github.com/jupyterlab/jupyterlab/issues/12019#issuecomment-1145841583

There is a problem when opening Jupyter Notebook

I installed Anaconda 3 in Linux and tried to open Jupyter notebook in browser by typing 'jupyter notebook' in terminal.
But what I've got is the screen I added below.
As I guess, Jupyter Notebook is currently opened via 'Elinks', but I have no idea about what this is.
Do you know how to open Jupyter Notebook in the browser I want, such as Firefox or Chrome?
I wanted to add some information in case you wanted to later access juypter notebook via elinks (or any other text-based web browser in terminal).
I will also go over opening jupyter notebook with Anaconda Navigator.
First, You need to first install Node.js Javascript Runtime Environment by running this command in terminal.
sudo apt-get install node.js
Next, close and reopen terminal (I always do this when installing new software via command line).
When you next try to access your jupyter notebook via elinks it will ask for a token or password.
Option 1 : Token.
Find the token by entering jupyter notebook list in terminal.
Option 2 : Password.
You can create a password for jupyter notebook by entering jupyter notebook password in the terminal.
You can now use the token or your newly created password in order to access jupyter notebook via full-featured text web browser such as elinks.
If you want to access jupyter notebook via Firefox, Chrome, etc. then just use anaconda. This will automatically open jupyter notebook in your standard web browser.
Enter anaconda-navigator in terminal.
Once anaconda navigator opens, simply launch jupyter notebook from the selection.
You can set Firefox or Chrome as default browser, then it should open directly in it.
If it still doesn't, you can always copy the URLs which are displayed when jupyter notebook is started, and paste it in your browser.
To access the notebook, open this file in a browser:
file:///home/harshit/.local/share/jupyter/runtime/nbserver-2985-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=9fc770713dbd755750bbe842896420ecfa7abc038581fc04
or http://127.0.0.1:8888/?token=9fc770713dbd755750bbe842896420ecfa7abc038581fc04
By the way, jupyter notebook doesn't work, because, by default, JS is not enabled in eLinks browser (you can enable it).

Issue running jupyter notebook via wls

Installed WSL on Windows 10.
Installed Anaconda according to the Anaconda documentation with the following commands:
bash Anaconda3-2020.02-Linux-x86_64.sh
source ~/.bashrc
You can see the '(base)' in the beginning of each command input line, indicating the conda is activated.
Then I run jupyter notebook by typing:
jupyter notebook
Then I see the following changes as shown in the screen record.
Briefly, the WSL terminal window showed some information very quickly, but is changed to the windows powershell window before you could even tell the information that showed up. I know those information should contain a file and url for opening the jupyter notebook in the web browser. But they flashed out so quickly. Does anyone know why this happens?
Here is a dynamic graph of the Screen record of this issue:
Solved:
1. Wait for a bit more time on the windows cmd and the jupyter notebook running information will show up, where includes the url to open jupyter notebook in the web browser.
OR
Open up another wsl terminal, activate the same environment and type jupyter notebook list, which will show the current running jupyter notebook server. The url is also can be found there.

Unable to start Jupyter lab or Jupyter notebook in a browser

I get the following log when starting Jupyter lab or Jupyter notebook-
[W 17:03:08.963 NotebookApp] No web browser found: could not locate runnable browser.
and Jupyter does not start a browser (or a tab in a browser).
(I am using Linux - Manjaro i3 community edition)
I have configured Jupyter to use google-chrome-stable by
jupyter notebook --generate-config
and setting the following line in ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.browser = '/usr/bin/google-chrome-stable'
(Yes I have uncommented the above line)
/usr/bin/google-chrome-stable and google-chrome-stable successfully launch chrome from the terminal.
I have also tried
jupyter lab --browser=google-chrome-stable
jupyter lab --browser google-chrome-stable
without success.
Jupyter used to open in a browser when I had Pale Moon installed on my system, but now that I have removed it, I cannot seem to get this working. google-chrome-stable is my default browser now.
The obvious workaround is to copy the localhost URL to a web browser but I am trying to avoid that.
Posting dsjamieson's answer here:
You have to give your browser (“google-chrome-stable” in this case) a string format argument (%s) in order to pass it the notebook’s URL:
jupyter lab --browser="google-chrome-stable %s"
or, if you prefer opening chrome in app mode:
jupyter lab --browser="google-chrome-stable --app=%s"
For Jupyter Lab, to make this more permanent:
jupyter-lab --generate-config
Then edit ~/.jupyter/jupyter_lab_config.py and set the ff:
c.ServerApp.browser = 'google-chrome-stable %s'
Or do a variation of double0darbo's answer above.

Why can't I connect to local runtime? Following google's tutorial gives me syntax errors

I'm running a topic modeling project and I need to run it on a much larger dataset (a 2GB xml file). The file won't upload to google drive and I decided to just try to run the code on my machine so because I need to run it faster as well. I decided to install Jupyter on my machine and tried to understand how to use my GPU on my local runtime I found another source here, where they provide a tutorial from google on how to connect to the local runtime:
How to make Jupyter Notebook to run on GPU?
However, the very first line of code there gave me a syntax error!
!pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws
File "<ipython-input-2-77e87048a5d2>", line 2
jupyter serverextension enable --py jupyter_http_over_ws
^
SyntaxError: invalid syntax
I don't understand python code that well and I just want this thing to work. I don't know how to fix these syntax errors. I tried to run the other lines of code as well but all of them have syntax errors. I tried pasting that code to my original colab file on google colab and on my local copy on jupyter and it won't work.
The first line can be run either on a terminal or in python shell.
However, the second shell is to be run on a terminal and for this, of course, you need to have jupyter installed in your local system.
$ jupyter serverextension enable --py jupyter_http_over_ws
I was having this problem myself and saw this question unanswered. The above did the trick for me !

Resources