i have two machines connected via lan.
other system's ip address is 192.1xx.x.x
i want to run jupyter ipython query's on my machine which can be exexuted on his machine.
at the start of ipython notebook, there is a black screen which contains this:
[I 11:12:52.802 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
can i change this to my specified location?
You can specify the port you want Jupyter to run uncommenting/editing the following line in ~/.jupyter/jupyter_notebook_config.py:
#c.NotebookApp.port = 8888
In case you don't have a jupyter_notebook_config.py try running jupyter notebook --generate-config. See this for further details on Jupyter configuration.
In case you are accessing Jupyter at a remote machine you can also try just leaving Jupyter running at its default port and make an SSH tunnel to your local machine at the port you want, e.g.:
ssh -fNL <new port>:localhost:8888 <your ssh config>
Run the Anaconda Prompt, generate the config file, if you don't have it and edit the config file and change c.NotebookApp.ip with your IP Adress '192.1xx.x.x'
On Anaconda Prompt:
If the file not exist, generate a config file:
jupyter notebook --generate-config
Output:
(base) C:\Users\youruser>jupyter notebook --generate-config
Writing default config to: C:\Users\youruser\.jupyter\jupyter_notebook_config.py
(base) C:\Users\youruser>
Change to jupyter directory:
cd .jupyter
Modify the config file from:
## The IP address the notebook server will listen on.
#c.NotebookApp.ip = 'localhost'
To:
## The IP address the notebook server will listen on.
c.NotebookApp.ip = '192.1xx.x.x'
First you need to generate a configuration file by typing:
$> jupyter notebook --generate-config
Writing default config to: /{home-directory}/.jupyter/jupyter_notebook_config.py
Next you need to edit that configuration to change the port number:
vi /{home-directory}/.jupyter/jupyter_notebook_config.py
Look for the following line (which is commented out by default) and comment in the line and change the port number:
(default configuration)
## The port the notebook server will listen on.
# c.NotebookApp.port = 8888
(comment removed, port changed)
## The port the notebook server will listen on.
c.NotebookApp.port = 9999
On a Mac, I had to use my machine's name instead of localhost.
To get this, open a terminal and run:
hostname
So in the browser, instead of localhost:8888/... I entered mac-mini.home:8888/... (where ... represents the rest of the url).
I'd like to find out where in the Jupyter config this can be overridden, because it is not intuitive, IMO.
Related
I work on an HPC where we have a login node to login and then we can ask for a specific amount of computing resources which will then be allocated on compute node. We cannot run our programs in login node since it is shared. Currently, if we want to run jupyter on the compute node, we have to ssh into the compute node and forward the port.
Is there any way to ssh into compute node so that we can run the jupyter notebook from vs code itself? If I run it directly it will run in login node which is a problem.
You can ssh into a compute node that is accessible through a login node by setting up your VSCode ssh config file such that your login node is a ProxyJump and your compute node the host you want to ssh to.
If you would log in to your login node as ssh username#ip.of.login.node, and from the login node, you can ssh to the compute node as ssh ip.of.compute.node, then you can set up your config file as such:
Host loginnode
HostName ip.of.login.node
User meulemeester
Host computenode
HostName ip.of.compute.node
User meulemeester
ProxyCommand ssh -vv -W %h:%p <ip.of.login.node>
# -W flag is necessary to redirect stdin and stdout
# %h:%p is hostname and portname. Host refers to ProxyJump (i.e. loginnode), port is 22 by default
ProxyJump loginnode
Make sure that this config file is the file used when running ssh. Check the VSCode setting Remote.SSH: config file to see if it points to this config file. Instead of using the IPs fo the login node or compute node, you can also use the host names directly (i.e. anything you would put after the # when ssh'ing).
Depending on the authorisation methods, you may want to add additional parameters to the config file. The given setup works if the host has the public key of the local machine stored under ~/.ssh/authorized_keys.
The compute node should now be available as an option when you want to connect to a host in VSCode.
I'm exploring the new set extensions called VSCode Remote Pack and I want to connect to a Vagrant container using the Remote Container extension. Using a Windows 10 OS, how could I do that?
I tried the extension but it requests me to have Docker installed, what I suppose from that is that it only works for Docker containers. But I wonder if somebody have already managed to connect to a Vagrant box.
This are the docs from the extension: https://code.visualstudio.com/docs/remote/containers
VS Code Remote containers currently only support Docker (its implementation executes docker commands). Please open a feature request if you would like to see other tools supported.
As an alternative, you could try using Remote SSH to connect to vagrant containers. That should work but will require some extra container setup
Sorry for updating this so late.
The solution was pretty simple, as #MnZrk commented, what it needs to be done for setting up the connection is the following:
Run vagrant ssh-config > some-file.txt. This will generate a file with the configuration to run using SSH. Here an example of that file:
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/User/project/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
ForwardX11 yes
Notice that the host name is default, you could rename it to whatever you want so you could identify it more easily.
Copy the content of some-file.txt inside your SSH configuration file. This file could be edit directly from vscode by pressing F1 and writing Remote-SSH: Open Configuration File..., then you select the file you use for ssh configuration. After that file opens, just copy the content of some-file.txt there.
Finally, just press again F1 and type Remote-SSH: Connect to Host..., choose the connection with the host name default or the want you wrote in the first step, and that's all.
I am using a windows machine and I have several running sessions of the jupyter notebook. Each session display the content in different ports. I would like to know if there is a way of getting a report including the different sessions I am running and the different ports on which they are displaying the content. I could not find that in the documentation.
Usually what you can do is pass the --help flag to the jupyter notebook command and read the informations in particular here
$ jupyter notebook --help
The Jupyter HTML Notebook.
This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.
Subcommands
-----------
Subcommands are launched as `jupyter-notebook cmd [args]`. For information on
using subcommand 'cmd', do: `jupyter-notebook cmd -h`.
list
List currently running notebook servers.
stop
Stop currently running notebook server for a given port
password
Set a password for the notebook server.
Options
-------
...
Oh ! A list sub command. let's try it:
$ jupyter notebook list
Currently running servers:
http://localhost:8888/ :: /Users/myuser/dev/ipython-website
http://localhost:8889/ :: /Users/myuser
.. well that's on macOS, but you should get the same on Windows.
One of the questions is why do you have multiple sessions as the notebok can browse the filesystem. It is likely confusing.
Enjoy.
I use Jupyter Notebook to run bioinformatic analyses, and I love it. However, it only really plays nice when I run it on my personal computer. However, I regularly do analysis using a remote computer with multiple cores to reduce processing time. I'd like to be able to use the Jupyter Notebook interface on my personal computer while everything is actually running on the remote computer. I generally do this via ssh access to the remote computer within the shell and execute all commands at the command line. I'd love to do this from the Jupyter notebook on my personal computer, rather than from the shell on my personal computer. It is relevant that I don't have sudo access on the remote computer.
So far, I've installed miniconda and jupyter notebook on the remote computer like this:
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
Once conda is installed properly, I install jupyter notebook via miniconda with this line:
conda install jupyter
This installs successfully. I can then start a jupyter notebook session on the remote machine with the line:
jupyter notebook --no-browser
So far, so good. My next question: How do I have my local jupyter notebook connect to the remote machine, so that I can execute commands on the remote machine using my local jupyter notebook? There is some documentation here, however i have been trying different things for hours, but have failed to succeed.
Can anyone give a straight forward method to connect to my remote server, given that I am this far along? I feel like it should just be a matter of entering url addresses and passwords into my local Jupyter notebook (all of this is so easy via ssh in the shell).
Follow the steps below:
Enable port forwarding on remote machine
ssh -N -f -L 127.0.0.1:8898:127.0.0.1:8898 user#remote-machine.com
Do ssh to your remote machine and then run following command on remote machine
jupyter-notebook --no-browser --port=8898
you will see some thing as shown below
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8898/token=eaf2f51f9c053f43d8bd093e76f0cc6301b545549c998fa2&token=eaf2f51f9c053f43d8bd093e76f0cc6301b545549c998fa2
Copy and paste the URL in your local machine browser.
If you want to access Jupyter/Ipython notebook running on a VPS remotely, I wrote a tutorial on the digital ocean community site.
As shown in the guide, after installing and running Ipython Notebook using command line on the server, you can connect to the notebook using SSH tunnelling with Putty (on windows) or the ssh -L command on Unix-like systems (ie Mac and Linux)
I am taking my first steps with ipython notebook and I installed it successfully on a remote server of mine (over SSH) and I started it using the following command:
ipython notebook --ip='*' ---pylab=inline --port=7777
I then checked on http://myserver.sth:7777/ and the notebook was running just fine. I then wanted to close the SSH connection with the server and keep ipython running in the background. When I did this, I couldn't connect to myserver.sth:7777 anymore. Once I connected again to the remote server by SSH, I could connect again to the notebook. I then tried to use screen to start ipython: I created a new screen by screen -S ipy, I started ipython notebook as above and I used Ctrl+A,D to detach the screen and exit to the TTY. I could still connect remotely to the notebook. I then closed the SSH connection and I got a 404 NOT FOUND error when I tried to access my previously stored notebook and I couldn't see it on the list of notebook at http://myserver.sth:7777/. I tried to create a new notebook, but I got a 500 Internal Server Error.
I also tried running ipython notebook with and without using sudo.
Any ideas?
Rather than use screen, perhaps you could switch to an init script or supervisord to keep IPython notebook up and running.
Let's assume you go the supervisord route:
Install supervisord
Install supervisord using your package manager. For ubuntu it's named supervisor.
apt-get install supervisor
If you decide to install supervisor through pip, you'll have to set up its init.d script yourself.
Write a supervisor configuration file for IPython
The configuration file tells supervisor what to run and how.
After you install supervisor, it should have created /etc/supervisor/supervisord.conf. These lines should exist in the file:
[include]
files = /etc/supervisor/conf.d/*.conf
If they contain these lines, you're in good shape. I only show them to demonstrate where it expects new configuration files. Your configuration file can go there, named something like /etc/supervisor/conf.d/ipynb.conf.
Here's a sample configuration that was generated by Chef by an ipython-notebook-cookbook that runs the notebook in a virtualenv:
[program:ipynb]
command=/home/ipynb/.ipyvirt/bin/ipython notebook --profile=cooked
process_name=%(program_name)s
numprocs=1
numprocs_start=0
autostart=true
autorestart=true
startsecs=1
startretries=3
exitcodes=0,2
stopsignal=QUIT
stopwaitsecs=10
user=ipynb
redirect_stderr=false
stdout_logfile=AUTO
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=10
stdout_capture_maxbytes=0
stdout_events_enabled=false
stderr_logfile=AUTO
stderr_logfile_maxbytes=50MB
stderr_logfile_backups=10
stderr_capture_maxbytes=0
stderr_events_enabled=false
environment=HOME="/home/ipynb",SHELL="/bin/bash",USER="ipynb",PATH="/home/ipynb/.ipyvirt/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games",VIRTUAL_ENV="/home/ipynb/.ipyvirt"
directory=/home/ipynb
serverurl=AUTO
The above supervisor config also relies on an IPython notebook configuration (located at /home/ipynb/.ipython/profile_cooked/ipython_notebook_config.py). This makes configuration much easier (as you can also set up your password hash and many other configurables).:
c = get_config()
# Kernel config
# Make matplotlib plots inline
c.IPKernelApp.pylab = 'inline'
# The IP address the notebook server will listen on.
# If set to '*', will listen on all interfaces.
# c.NotebookApp.ip= '127.0.0.1'
c.NotebookApp.ip='*'
# Port to host on (e.g. 8888, the default)
c.NotebookApp.port = 8888 # If you want it on 80, I recommend iptables rules
# Open browser (probably want False)
c.NotebookApp.open_browser = False
Re-read and update, now that you have the configuration file
supervisorctl reread
supervisorctl update
Reality
In reality, I used to use a Chef cookbook to do the entire installation and configuration. However, using configuration management with tiny stuff like this is a bit of overkill (unless you're orchestrating these in automation).
Nowadays I use Docker images for IPython notebook, orchestrating via JupyterHub or tmpnb.