Q2. Unable to install/activate jupyter_http_over_ws for Jupyter on Google Colab - runtime

For Local runtimes, Colaboratory lets you connect to a local runtime using Jupyter. This allows you to execute code on your local hardware and have access to your local file system. I am trying to make jupyter_http_over_ws work.
Running these scripts accordingly but I am getting stuck and it is bouncing with errors-Screenshot 1.
I even tried running the last scripts to Start the server and authenticate but getting stuck but it too is getting frozen at a point- Screenshot 2.
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
Screenshot 1
Screenshot 2

First make sure you have installed jupyter notebook and jupyter_http_over_ws properly, then execute this in command prompt:
jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com' --port=8888

Related

Jupyter in VSCode Failing to Start Kernel

I've been using Jupyter within VSCode with no problems for a couple weeks, but since this morning it has been unable to start a kernel to run my code.
Typically, I can just open any .ipynb file in VSCode and immediately run it with no problems. That's giving me the message:
Failed to start the Kernel.
Jupyter server crashed. Unable to connect.
Error code from Jupyter: 1
usage: jupyter.py [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
[--paths] [--json] [--debug]
[subcommand]
Jupyter: Interactive Computing
positional arguments:
subcommand the subcommand to launch
options:
-h, --help show this help message and exit
--version show the versions of core jupyter packages and exit
--config-dir show Jupyter config dir
--data-dir show Jupyter data dir
--runtime-dir show Jupyter runtime dir
--paths show all Jupyter paths. Add --json for machine-readable
format.
--json output paths as machine-readable json
--debug output debug information about paths
Available subcommands: dejavu lab labextension labhub nbconvert
Jupyter command `jupyter-notebook` not found.
View Jupyter log for further details.
I can, however, open a local host in a browser using:
python3 -m notebook
in my terminal.
Any help is greatly appreciated.
I had the same problem. Seems there was an issue in a previous release of the Jupyter extension for VScode (see : [1])
I resolved as suggested in [1] :
uninstall jupyter from your global environment
set up a virtual environment
install jupyter in the new virtual env
select the virtual env as kernel used in VScode
run some cells (should work)
In case you want to use jupyter in your global environment :
remove the virtual environment
reinstall jupyter in your global env
select the correct global env interpreter in VScode
[1] https://github.com/microsoft/vscode-jupyter/issues/12714

Tunneling from Windows 10 to Jupyter running on AWS

I'm trying to access Jupyter notebooks that are installed on AWS and I want to use a windows-10 machine to access it. The jupyter system sits behind a jump host (bastion) on aws. The process works for macs in the following way
- Instructions exist to create a ssh tunnel
- Magically the notebook is available on a browser by doing localhost:8223
The mac command for it looks like
ssh -i /pathto.id_rsa -L 8223:<some name>:8223 -f -o <some other url>
What I've been able to accomplish is the following.
- Installed putty and pageant. Set up key forwarding on putty and been able to log in to the bastion host.
- I tried foxyproxy on chrome but couldn't make much headway there.
How do I access this Jupyter notebook from windows?
Again, the set up is
windows --> [bastion] --> jupyter
I'm totally lost, any pointers or step by step instructions is much appreciated.
Try this article from my blog: https://vrnchndk.in/2017/01/27/access-blocked-websites-using-ssh-tunnel/
It has step by step instructions with screenshots as well.

How to launch jupyter notebooks on server via ssh and run it on local browser?

I'm working on a project where the servers and Mysql data bases are inaccessible from my local machine unless I ssh to a remote using terminal. However, I find programming with Jupyter Notebooks the best environment for me. I really miss it as I find programming with just vim remotely via terminal a bit cumbersome. I was wondering if there was a way to launch Jupyter notebook from the server and have my local browser open it up- so I can code from my browser but it would be running from the terminal/remote-server via ssh- so that ways my code can actually connect to my database from my browser via the remote and I can use the interactiveness of a Jupyter notebook to speed up my development. Any ideas? remote is ubuntu and mine is a mac. Thanks
This is pretty simple. You just need to install the jupyter notebook server on your remote machine and make it open to the web, protected by a password to avoid unintended use.
On the remote server, first install Jupyter:
pip3 install jupyter
Then follow this guide to secure it with a password.
At last you can launch it with:
jupyter notebook --ip='*'
This tells Jupyter to make it available from any ip and not only from localhost.
Please do protect it with a password, otherwise very nasty things could happen to your server.

Root access for Jupyter/iPython Notebook

I'm trying to use the bash kernel in iPython/Jupyter notebook, but I need sudo access within the notebook itself.
I've tried $ sudo jupyter notebook to run the notebook as root, but that only returns:
$ jupyter: 'notebook' is not a Jupyter command
So, I'm left with running $ jupyter notebook (unless there's a way to run Jupyter notebook as root).
I also can't do su root in the notebook itself because that requires an input and the notebook won't let me give an input.
Finally, there is allegedly an --allow-root option for Jupyter notebook:
http://jupyter-notebook.readthedocs.io/en/latest/config.html
However, it looks like --allow_root is no longer an option. (I've tried modifying the config file by adding NotebookApp.allow_root=True, but that doesn't work.)
Any ideas guys? Maybe I'm doing something wrong?
Just login as root, then do the following command to start the notebook :
jupyter notebook --allow-root
The solution as described here. Is to use
sudo -E env "PATH=$PATH" jupyter notebook
Basically the binary to call jupyter notebook is in the user's PATH variable, but not for root.
Best regards.
Add c.NotebookApp.allow_root=True from the root configuration files. That you don't need ask to allow-rootevery time then you start the notebook.
Edit:
Before edit the configuration file you need to run jupyter notebook --generate-config as root to make the file.
I am running the neopixel library from a jupyter notebook.
The only thing that worked for me was first running the "sudo su" command to move into the root environment and then run "jupyter notebook" (--allow-root alone didn't work for me).
You should try running the command sudo jupyter notebook --allow-root , I'm not sure why but this works. On the server it'll ask you for a password, if you have set up a password for it just type it in the box that will be shown, otherwise, type jupyter notebook password to set up a new password
Generate config
root#user# jupyter notebook --generate-config
root/.jupyter/jupyter_notebook_config.py
root#user# cd .jupyter/
root#user:/.jupyter/# gedit jupyter_notebook_config.py
Add line in jupyter_notebook_config.py
c.NotebookApp.allow_root=True
When I need to execute command as root in my notebook, I use the -A flag, that allows to access an helper program used to read the user's password when no terminal is available.
You need to modify the sudo.conf file before to declare the helper program. On a Debian Buster, I personnaly added:
Path askpass: /usr/libexec/seahorse/ssh-askpass
See the main page of sudo.conf for more information.
In case anyone is still looking for an answer, this is what worked for me:
sudo ~/.local/bin/jupyter-notebook --allow-root
Switching user using su didn't work because I didn't have jupyter installed on root. Using just --allow-root by itself also didn't work for me. This allows you to run sudo with jupyter notebook without running into the issue of "notebook" not being a valid command. Because I am using a linux terminal, jupyter-notebook is installed at ~/.local/bin/jupyter-notebook. See After installing with pip, "jupyter: command not found" for more information about where jupyter may be installed.

Having difficulty accessing the Jupyter notebook when trying to run TensorFlow through Docker

My problem:
Newbie to the ML field here. I am currently attempting to set up tensorflow through docker but am having some troubles getting to the jupyter notebook once tensorflow appears to be running. For future reference, I am using windows 10, powershell, python 2.7, and oracle virtualbox (v.5.0.16).
I am pretty confident that docker is working properly because I went through their setup tutorial ("Using docker from Powershell") without any issues--I was able to run the hello world example there just fine. I was also able to successfully run an ubuntu terminal with the command
docker run -it ubuntu bash
I then followed the tensorflow docker installation instructions and everything appeared to be normal--I entered the docker run command for tensorflow:
docker run -it b.gcr.io/tensorflow/tensorflow
and got this output:
[I 19:33:16.330 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 19:33:16.360 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[W 19:33:16.360 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.
[I 19:33:16.365 NotebookApp] Serving notebooks from local directory: /notebooks
[I 19:33:16.365 NotebookApp] 0 active kernels
[I 19:33:16.365 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/
[I 19:33:16.366 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
However, when I attempt to get to the jupyter notebook at localhost:8888, chrome says the site cannot be reached within a few seconds and that the server refused to connect.
Solutions I have tried:
Followed the advice in this stackoverflow post. When I run the command they suggest to start a new tensorflow container, I get the error:
exec: "./run_jupyter.sh": stat ./run_jupyter.sh: no such file or directory
docker: Error response from daemon: Container command not found or does not exist..
I also changed the port settings using virtualbox like they suggested, and this also did not seem to make a difference.
Instead of going to localhost, I tried the IP addresses listed for the driver when I use the command docker-machine ls. No luck here either.
My first attempt was using the quickstart terminal that comes with docker, and I got stuck in the same place. So now I have a "default", from when I set up docker using the quickstart terminal, and a "my-default", from when I set up docker using powershell. Stackexchange comments have said that the quickstart terminal doesn't work as well as just using powershell, so I have started using powershell instead.
Tried changing which driver was active using docker-machine env and then running the tensorflow run command for that driver's IP address, and still had no luck.
Tried skipping the jupyter notebook and just running everything from the command line through python as suggested in the next step of the tensorflow install ("Run tensorflow from the command line") and I could not even import tensorflow from there:
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
I don't know if this is possible without running jupyter first but I thought it was worth a shot. This problem might be unrelated to the one this post is about, but if anyone has an idea as to why this is, that would be helpful too.
I appreciate any and all help that is offered. Please let me know if anything I stated is vague, or if I can offer any more details on what I have tried. Thank you very much in advance.
Try adding -p 8888:888 to the docker run command.
docker run -p 8888:8888 -it b.gcr.io/tensorflow/tensorflow
Found the solution in this tensorflow issue, in a comment by HWiese1980
Since Docker usually needs to have the same operating system on the Docker host system as it's in the Docker container (well, parts that is) you need a Linux VM to run a Docker container that is based on Linux under Windows. Docker itself opens port 8888 between the VM and the container. You have to explicitly tell it to forward the port from the outside of the VM to the open Docker container port by using said parameter -p 8888:8888.
For ubuntu 14.04 I had to use the below command to specify '/bin/bash' so that it would enter the interactive console.
docker run -it gcr.io/tensorflow/tensorflow /bin/bash

Resources