I'm having a weird problem with Jupyter notebook running inside a WSL2 instance. Every time I start a new notebook, my first connection to localhost:8888 (or localhost:XXXX for any other port number) takes a LONG time to connect, like 5-10 minutes. Once one connection to that port has been made, however, all subsequent connections happen at a normal speed. As far as I can tell the delay is not specifically happening within the Jupyter server, as the server output doesn't show any GET requests during the waiting period:
> jupyter notebook .
[I 08:29:21.282 NotebookApp] Authentication of /metrics is OFF, since other authentication is disabled.
[W 08:29:21.729 NotebookApp] All authentication is disabled. Anyone who can connect to this server will be able to run code.
[I 08:29:21.732 NotebookApp] Serving notebooks from local directory: /home/peter/jade_poplar/code/python
[I 08:29:21.732 NotebookApp] Jupyter Notebook 6.4.0 is running at:
[I 08:29:21.732 NotebookApp] http://localhost:8888/
[I 08:29:21.732 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
...
5-10 MINUTES ELAPSE
...
[I 08:38:12.718 NotebookApp] 302 GET / (127.0.0.1) 2.110000ms
However, the issue does appear to be limited only to Jupyter: if I just listen on the port with nc -l 8888 and then point my browser to localhost:8888 the GET request shows up immediately.
I have tried random fixes to other problems that I found on SE, eg. this one, but to no avail. Any advice, or even a suggestion as to where to start looking, would be greatly appreciated! This is driving me bonkers, although I am getting a lot of chess in while I wait for my notebooks to load :D
Old answer
I found 2 ways to get around the "waiting time" on my system.
Hit Ctrl+C once after the console output hangs at Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Set the DISPLAY environment variable to nothing: DISPLAY= jupyter notebook .. Apparently, the same trick works for pip.
UPDATE 1
After some debugging I figured out, that the --no-browser option does the trick as well:
jupyter notebook --no-browser .
jupyter-notebook by default opens localhost:8888 in the browser.
I assume WSL2 has problems opening the default browser, and therefore times out.
UPDATE 2
To confirm my guess, from UPDATE 1, I set up WSL to be able to open a browser window:
Installing firfox in WSL (ubuntu):
sudo apt install firefox
Setting up X11 forwarding on WSL2
Using this setup jupyter-notebook starts normally and localhost:8888 is opened in firefox.
Related
By mistake I rebooted my system with open Notebooks in Firefox browser. Ever since I cannot get a Jupyter Server running properly from my Anaconda.
As expected, I can get to the base folder on my system but as soon as I click to open a new folder or notebook the server throws the error Server error: Forbidden at me.
The error seems to be related to login cookies:
[I 08:16:34.286 NotebookApp] 302 GET /?token=1aed47898bede70ff7f27f2518660b343cd64995372d9d58 (127.0.0.1) 0.000000ms
C:\Users\sb123\.conda\envs\Thesis2\lib\site-packages\jupyter_server\base\handlers.py:240: UserWarning: The Tornado web application does not have an 'identity_provider' defined in its settings. In future releases of jupyter_server, this will be a required key for all subclasses of `JupyterHandler`. For an example, see the jupyter_server source code for how to add an identity provider to the tornado settings: https://github.com/jupyter-server/jupyter_server/blob/aa8fd8b3faf37466eeb99689d5555314c5bf6640/jupyter_server/serverapp.py#L253
warnings.warn(
[E 08:16:34.650 NotebookApp] Error unpacking user from cookie: Expecting value: line 1 column 1 (char 0)
[W 08:16:34.650 NotebookApp] Clearing invalid/expired login cookie username-127-0-0-1-8890
[I 08:16:34.651 NotebookApp] 302 GET /server-proxy/servers-info (127.0.0.1) 3.000000ms
[W 08:16:36.070 NotebookApp] Forbidden
[W 08:16:36.070 NotebookApp] 403 GET /api/contents/Documents?type=directory&_=1673594194483 (127.0.0.1) 1.000000ms referer=http://127.0.0.1:8890/tree/Documents
The error can be reproduced across webbrowsers (I tried Firefox and Edge).
When I launch the server from within Pycharm Pro however, I can open, edit and run notebooks without a problem, both in the IDE as well as in Firefox.
I did not find any hints on the web and would be grateful for your support.
Many thanks!
I have exactly the same problem (in a pip venv).
For me, pip install --upgrade 'jupyter-server<2.0.0' did the trick for the time being. This is obviously not a "solution", but so far I have no idea how to find out what is wrong.
I am a single user on a local maching - it seems it has something to do with security. I don't want to deal with complicated login methods. Token based is absolutely sufficient.
I am running Jupyter lab on my WSL2 Ubuntu and accessing it in Firefox on my Win10 PC. They are running on the same machine, so there should be no "Network" involved. I am running it as jupyter lab --no-browser. The Server launches just fine in the terminal:
[I 11:17:40.843 LabApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 11:17:40.885 LabApp] JupyterLab extension loaded from /home/muthur/anaconda3/lib/python3.8/site-packages/jupyterlab
[I 11:17:40.886 LabApp] JupyterLab application directory is /home/muthur/anaconda3/share/jupyter/lab
[I 11:17:40.888 LabApp] Serving notebooks from local directory: /home/muthur
[I 11:17:40.888 LabApp] Jupyter Notebook 6.2.0 is running at:
[I 11:17:40.888 LabApp] http://localhost:8888/?token=...
[I 11:17:40.888 LabApp] or http://127.0.0.1:8888/?token=...
[I 11:17:40.888 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
But when I start it in my browser, I first get "Server Connection Error: A connection to the Jupyter server could not be established. JupyterLab will continue trying to reconnect. Check your network connection or Jupyter server configuration.", which in the F12 console is due to Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. Reloading the tab or opening it in a new one gives me the Firefox "Connection failed" error page, saying that it cannot establish a connection to 127.0.0.1:8888
I have been using this setup for the past 2-3 months without issue. Any idea why this crops up now, and how to solve it?
They are running on the same machine, so there should be no "Network" involved.
Believe it or not, there's definitely a network involved when communicating between Windows and a WSL2 session. While WSL1 ran "on" the host Windows network (pseudo-bridged), WSL2 runs in a separate VM that has its own virtual NIC. That NIC is NAT'd behind the Windows interface by default.
This means that port-forwarding is needed, so that when you access port 8888 on localhost (127.0.0.1) in the Windows browser, it is forwarded to the virtual NIC for the WSL2 instance.
By default, this happens automatically (see the localhostForwarding setting on that page). However, sometimes it doesn't. Typically, it "breaks" when Windows is hibernated or shut down with "Fast Restart" enabled (which also does a "mini-hibernate"). Note that Fast Restart is the default in Windows, so it's easy to run into this problem.
The solution is fairly straightforward, assuming that this is the problem that you are seeing:
Exit out of any running WSL instances
wsl --shutdown at the PowerShell or CMD prompt
Restart your WSL instance
Things will hopefully hum along just fine until your next hibernate.
More info and other suggestions to try if that doesn't work at this answer.
jupyter-notebook was working fine until I upgraded to macOS High Sierra. Anyone know how to resolve the "osacript: can't open default scripting component" problem? Searching this site and Google yielded no answers. I'm on Anaconda 4.3.24. Thanks.
$ jupyter notebook
[I 08:12:13.340 NotebookApp] The port 8888 is already in use, trying another port.
[I 08:12:13.360 NotebookApp] Serving notebooks from local directory: /Users/Greenhorn/Local/projects
[I 08:12:13.360 NotebookApp] 0 active kernels
[I 08:12:13.360 NotebookApp] The Jupyter Notebook is running at: http://localhost:8889/?token=9d8bde3a675f28b3cbc4c87b7eb0c36788b4d28260d9ed39
[I 08:12:13.360 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 08:12:13.361 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8889/?token=9d8bde3a675f28b3cbc4c87b7eb0c36788b4d28260d9ed39
osascript: can't open default scripting component.
I just ran into exactly the same problem with osascript whilst diagnosing an issue with Emacs Applescript integration (Emacs reports the error as do-applescript: OSA language not available, but further debugging led me to osascript and its can't open default scripting component). I also recently upgraded to High Sierra.
Online one unfortunately finds too much advice that an OSX re-install is required.
In my case, a reboot fixed the issue.
You can diagnose by running the test command:
osascript -e 'tell app "Finder" to display dialog "Hello, World!"'
After the reboot, this should popup a "Hello, World!" dialog.
I've been using jupyter notebook in my root environment and a few other environment for several months. Upgraded to jupyter notebook 5 last week and it worked well until yesterday.
Yesterday - computer froze. After restarting, jupyter notebook gives an error (2x) when launched from root environment:
(some info replaced with # below)
[I 08:57:31.223 NotebookApp] Serving notebooks from local directory: #######
[I 08:57:31.223 NotebookApp] 0 active kernels
[I 08:57:31.223 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=########################
[I 08:57:31.223 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 08:57:31.224 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=########################
[I 08:57:32.992 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 08:58:01.367 NotebookApp] Kernel started: ###########
[I 08:58:02.775 NotebookApp] Adapting to protocol v5.1 for kernel ############
[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.version
[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.version
I've tried copying and pasting the link provided above. It removed one of the error messages next time it was launched, then 2 error messages after trying to launch again.
Jupyter notebook works when launched from a different conda environment.
Any thoughts on how to get this working in my root environment again?
I am trying to Login my Notebook via Browser, but Chrome shows "This webpage is not available"
I have the following on my terminal:
[ec2-user#ip-172-31-24-217 .ipython]$ ipython notebook --profile=nbserver
[I 11:31:38.289 NotebookApp] Using existing profile dir: u'/home/ec2-user/anaconda/.ipython/profile_nbserver'
[I 11:31:38.295 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[I 11:31:38.310 NotebookApp] Serving notebooks from local directory: /home/ec2-user/anaconda/.ipython
[I 11:31:38.311 NotebookApp] 0 active kernels
[I 11:31:38.311 NotebookApp] The IPython Notebook is running at: https://[all ip addresses on your system]:8888/
[I 11:31:38.311 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Can someone helps figure out what there is 0 active kernels? I have add the following in my ipython_nootbook_config.py file
#kernel config
c.IPkernelApp.pylab='inline' # if you want plotting support always
#Notebook config
c.NotebookApp.certfile=u'/home/ec2-user/anaconda/certificates/mycert.pem'
c.NotebookApp.ip='*'
c.NotebookApp.open_browser=False
c.NotebookApp.password=u'sha1:0d4773e470e5:2a91dcf5a15875f15c4ad18f9d3
4c95be563f804'
#It is a good idea to put it on a known, fixed port
c.NotebookApp.port=8888
#-------------------------
The number of running kernel has nothing to do with that.
Which page Are you visiting ? http://<ip>:8888 ? did you forgot the s in https ? Do you have Proxy settings ? Sophos antivirus ? On a Company network ?