I'm running Jupyter notebooks (Python 3) on a remote cluster that I'm connected/tunneled to over SSH.
Jupyter's default behavior is to try to open the dashboard in a web browser when it launches -- aparently (I only just updated), at some point they switched to the Python 3 webbrowser library for this.
According to webbrowser's documentation:
text-mode browsers will be used if graphical browsers are not available or an X11 display isn’t available.
This is exactly what happens. I run jupyter notebook, webbrowser launches elinks, and my one-time authentication token gets eaten, preventing me from connecting to the notebook.
Jupyter isn't configured to use a browser -- c.NotebookApp.browser is commented out in my config -- and running BROWSER="" jupyter notebook doesn't help either.
How can I force Jupyter not to open any browser?
jupyter-notebook --help includes the following:
--no-browser
Don't open the notebook in a browser after startup.
jupyter notebook --generate-config
Then edit ~/.jupyter/jupyter_notebook_config.py and Add
NotebookApp.open_browser = False
You can achieve this by specifying --no-browser:
$ jupyter notebook --no-browser
I also recommend that you specify the port you want to use:
jupyter notebook --no-browser --port= <port_number>
ie:
$ jupyter notebook --no-browser --port=8888
You have to keep in mind that when you do this, jupyter will provide you with a token on the console, token that the server will ask you when connect remotely through the browser.
If you want to simplify this procedure, you can set a password that is easier for you to remember. To do this, you can run in a console:
$ jupyter notebook --generate-config
and later:
$ jupyter notebook password
This last command will ask you for the password that you wish to use to enter remotely.
Regards!
Related
I use PyCharm Professional and I am trying to launch Jupyter Notebook inside PyCharm IDE.
I followed the official instructions Manage Jupyter notebook servers.
I installed Jupyter and configured python 3.8 interpreter using virtual environment. I do not use conda.
When I run the first cell "Starting Jupyter Server" message is shown on the Jupyter top bar. I now that I have to insert Jupyter password or activation token for the server.
When I run command inside PyCharm terminal it gives me only the address:
jupyter notebook list
Currently running servers:
http://localhost:8888/
As officials say here must be shown authentication token for the server, but it is missing.
So, where I can find this token to enter the Jupyter Server and see other server's configuration details?
I have just found the answer by myself.
I have Jupyter configuration already in the folder ~/.jupyter/jupyter_notebook_config.py where the password and other parameters are set. So, to enter the server all I had to do is to enter the password which I set on my own in the above configuration file in the past.
I can connect to a remote Jupyter Notebook server with a token from VSCode through the "Python: Specify Jupyter server URI" command from the Command Palette.
However, I couldn't find a way to do this:
Access the remote server's terminal to run command-line Python code. Using the ! magic in cells itself is not useful as the command line code is interactive.
Is there a way to do this?
A little late and not sure if it's the answer you were looking for, but I personally prefer to access remote server's terminal from Windows Terminal, you can set a profile for your server as shown here SSH in Windows Terminal
You can mix this with the extension Windows Terminal Integration for vscode
Would it possible to run Jupyter lab or notebook which is installed on a different machine on local network? Something like 192.168.1.8:port_address
Yes of course you can.
Start the the jupyter notebook with this:
jupyter notebook --ip <your_LAN_ip> --port 8888
Then visit:
http://your_LAN_ip:8888
from another computer.
You can easily change the port number 8888 to any number you want, for example 6006.
It's recommended that you use a password when accessing your notebook server. To set up a password, just run jupyter notebook password. Otherwise, someone can access to your notebook.
Here is the link for setting notebook's password: https://jupyter-notebook.readthedocs.io/en/latest/public_server.html#notebook-server-security
By following the tutorial from Running an iPython Notebook Server on AWS - EC2 Instance
I successfully configured the ipython notebook server on AWS EC2 instance, also I found that to use matplotlib module I have to ssh -X to the instance and then run:
nohup ipython notebook --profile=nbserver
and then set
%matplotlib inline
in the ipython notebook connected through https in the browser.
Now I want to automate the whole process so that I can directly open the browser to use the ipython notebook when starting an instance, just like the RStudio AMI created by Louis Aslett, so I tried:
crontab -e
then I add the following line to the end of this file
#reboot nohup ipython notebook --profile=nbserver
But but when I reboot this instance this command won't work. Also I don't know how to enable X11 forward in the start up script so that I can use matplotlib to plot. Can someone help me with this configuration?
Cron doesn't know your environment variables. So when you run ipython, it doesn't know where to find it from. To resolve;
First type
which ipython
then change this with the ipython part of your code
#reboot nohup /home/ubuntu/anaconda/bin/ipython notebook --profile=nbserver
(Maybe better ask on superuser?)
iPython works fine if I use an ssh tunnel.
Using ngrok
iPython notebook loads I get an error about mathjax not loading.
I can enter code into cells but if I try to execute I get no result but the kernel seems to be running. Basically nothing works. I have no idea if I am doing something wrong or if this just wont work.
I am starting starting ngrok like this
./ngrok -authtoken myauthtoken 5023
and ipython notebook like
ipython notebook --no-browser --port=5023
Then connect to the iPython session at
https://mysubdomain.ngrok.com
Author of ngrok here: ipython notebooks and any other websocket connections now work properly as of ngrok 0.22 which is available at https://ngrok.com/download