Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to Jupyter Notebook

My environment:

Windows 10 Professional Python 3.7.2 virtualenv 16.4.3

I created a new virtual environment with D:\Python37\Scripts\virualenv env

Then I activated the virtual environment with env\Scripts\activate

Then I installed jupyter with pip install --upgrade jupyter

Finally, I started jupyter with jupyter notebook

Everything starts up fine, and I create a new Python 3 notebook. Unfortunately, the notebook never connects to the server. I get the following error message in powershell

Replacing stale connection: (token)

In the browser, I get the following error message:

"A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration."

My two prior virtual environments (with Jupyter) work fine. I've deleted .ipython, .jupyter, AppData\Roaming\jupyter, without any luck.

I've cleared cookies from my browser and have tried a different browser. Nothing works.

I've created two other virtual environments before, and both of those still work.

All jupyter notebooks in the two working environments start up as untrusted, whereas the new environment starts up as trusted. I'm guessing that I clicked on something and now the notebook is looking to start up in a trusted fashion - which may require HTTPS.

Where do I look to fix this problem?

like image 641
Mark Eggers Avatar asked Mar 02 '19 01:03

Mark Eggers


People also ask

Why is my Jupyter notebook not connecting?

Try disabling any browser extensions and/or any Jupyter extensions you have installed. Some internet security software can interfere with Jupyter. If you have security software, try turning it off temporarily, and look in the settings for a more long-term solution.

How do I connect to jupyter?

Connect to a Jupyter server using OAuth authenticationicon on the toolbar of the Workspace tool window. Select Connect by URL and enter the target Jupyter server address in the Server URL field. Click the Link to the token page link. You will be prompted to login into GitHub.

Why is my Jupyter notebook not showing output?

Restart the kernel, run the cells again and let me know if the output shows up.

How do I access a Jupyter notebook from a browser?

you can go to chrome and type, http://{your ip address}:8888 to access the same jupyter notebook. Congratulations!


2 Answers

This appears to be a tornado issue. I found clues here.

  1. Jupyter no connection to server
  2. Jupyter kernel not connecting

I looked at the version of tornado (from the above links) in an environment that was working. It turns out that the version was 5.1.1.

I looked at the version of tornado in an environment that was NOT working. It turns out that the version was 6.0.

I downgraded the version of tornado in my non-working environment to 5.1.1 with the following command.

pip install --upgrade tornado==5.1.1

And now the non-working environment works!

like image 133
Mark Eggers Avatar answered Sep 28 '22 09:09

Mark Eggers


Anaconda is pretty good at handling any dependencies.I just tried this using Anaconda in the terminal:

# see current envs
conda info -e

# make new environment, feel free to add your version of python with python=3.7 handle
conda create -n test

activate test

conda list   #This should appear empty
conda install jupyter  #y to install everything.

jupyter notebook  #launch jupyter notebook

Mine comes up as 'trusted'. The method above may not necessarily be the most minimalist way of doing things, but at least nothing breaks and you're up in running in no time. I'm using conda version: 4.6.2

like image 40
Monty Avatar answered Sep 28 '22 08:09

Monty