Jupyter on docker cannot automatically open up browser when it executed - python

I've had docker to use the jupyter notebook with tensorflow.
(My OS is window 10 so I use the Powershell.)
I want the jupyter to open the web browser automatically. When I try to initialize jupyter notebook.
For instance, I enter the command to start anaconda image (including tensorflow).
> docker run -it -v ~/tensorwork:/notebooks -p 8888:8888 anaconda3
And activate tensorflow
(base) root#e088a0e0e58e:/# conda activate tensorflow
After entering tensorflow kernel mode, I execute jupyter notebook.
(tensorflow) root#e088a0e0e58e:/# jupyter notebook --ip '*' --allow-root
[I 14:47:00.827 NotebookApp] [nb_conda_kernels] enabled, 4 kernels found
[W 14:47:01.080 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 14:47:01.214 NotebookApp] [nb_anacondacloud] enabled
[I 14:47:01.219 NotebookApp] [nb_conda] enabled
[I 14:47:01.265 NotebookApp] ✓ nbpresent HTML export ENABLED
[W 14:47:01.265 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 14:47:01.268 NotebookApp] Serving notebooks from local directory: /
[I 14:47:01.269 NotebookApp] 0 active kernels
[I 14:47:01.269 NotebookApp] The Jupyter Notebook is running at:
[I 14:47:01.269 NotebookApp] http://[all ip addresses on your system]:8888/?token=55d0e39e50ff64ca52ab43516d06c96127704fb56de2d356
[I 14:47:01.269 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 14:47:01.270 NotebookApp] No web browser found: could not locate runnable browser.
[C 14:47:01.275 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=55d0e39e50ff64ca52ab43516d06c96127704fb56de2d356
Execution of the jupyter notebook works well.
However, I manually enter the URL my browser to enter the notebook.
I guess this problem came from docker's feature. The container's file path needs to be connected to the local host so that jupyter can find the default web browser(chrome) that I use.
But how can I make it possible? I've already tried the editing config of jupyter notebook.
Before I execute jupyter notebook, I enter the command as following:
jupyter notebook --generate-config
vim ~/.jupyter/jupyter_notebook_config.py # or use your favorite editor
c.NotebookApp.browser = u'chrome'
(refer ; https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/oXjbKNMyP30)
But the jupyter still said it cannot find any web browser. Help me please :)

Related

Google Colab local runtime connecting error

I want to connect Google Colab to my local jupyter runtime. I installed the below extension as suggested by colab.
pip install --upgrade jupyter_http_over_ws>=0.0.7 && jupyter serverextension enable --py jupyter_http_over_ws
Then I run the command and started a jupyter notebook. After that I try to connect google colab to the local runtime with the prompted URL. But then I got the follow issue. Please help me to solve this.
F:\Education\SEMESTER 7\CO421 FINAL YEAR PROJECT\PROJECT\josh>jupyter notebook --NotebookApp.allow_origin='https://colab.research.google.com'--port=8888 --NotebookApp.port_retries=0
jupyter_http_over_ws extension initialized. Listening on /http_over_websocket
[I 12:01:45.043 NotebookApp] Serving notebooks from local directory: F:\Education\SEMESTER 7\CO421 FINAL YEAR PROJECT\PROJECT\josh
[I 12:01:45.043 NotebookApp] Jupyter Notebook 6.1.4 is running at:
[I 12:01:45.043 NotebookApp] http://localhost:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
[I 12:01:45.043 NotebookApp] or http://127.0.0.1:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
[I 12:01:45.043 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:01:45.125 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/prasa/AppData/Roaming/jupyter/runtime/nbserver-6268-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
or http://127.0.0.1:8888/?token=9308f0fdb2a8ebe003eec56aa2684dfb7c51c873ba0d9214
[W 12:02:15.646 NotebookApp] Blocking Cross Origin API request for /http_over_websocket. Origin: https://colab.research.google.com, Host: localhost:8888
[W 12:02:15.647 NotebookApp] 403 GET /http_over_websocket?min_version=0.0.7&jupyter_http_over_ws_auth_url=http%3A%2F%2Flocalhost%3A8888%2F%3Ftoken%3D5d6bb0b08b718df4fMUpVa4LvtUpaHGkcUqPkMpyiaoG8817 (::1) 2.99ms referer=None

Jupyter notebook not working with Pycharm

I am trying to use jupyter notebook on Pycharm.
Following this article, I ran a simple Hello World code but nothing shows up.
I got some logs like this.
/home/ryuzot/anaconda3/envs/keras_playground2/bin/jupyter notebook --no-browser --port 8888
[I 00:52:46.955 NotebookApp] Serving notebooks from local directory:
/home/ryuzot/PycharmProjects/keras_playground
[I 00:52:46.955 NotebookApp] Jupyter Notebook 6.1.1 is running at:
[I 00:52:46.955 NotebookApp] http://localhost:8888/?
token=45771778a508593eb6b45db8b13b2661daea7a4b709846d6
[I 00:52:46.955 NotebookApp] or http://127.0.0.1:8888/?
token=45771778a508593eb6b45db8b13b2661daea7a4b709846d6
[I 00:52:46.955 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 00:52:46.957 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/ryuzot/.local/share/jupyter/runtime/nbserver-13870-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=45771778a508593eb6b45db8b13b2661daea7a4b709846d6
or http://127.0.0.1:8888/?token=45771778a508593eb6b45db8b13b2661daea7a4b709846d6
I change the port which jupyter is running to 8888 and 8080, but it didn't work.
I use Pycharm professional 2020.2, Jupyter Notebook 6.1.1 , Python 3.7 on openSUSE 15.2.
I hope to receive some help.
To start working with Jupyter notebooks in PyCharm:
Create a new Python project, specify a virtual environment, and install the jupyter package.
Open or create a .ipynb file.
Add and edit source cells.
Execute any of the code cells to launch the Jupyter server.
Analyze execution results in the Preview pane.

Jupyter notebook shows blank page in browser

I am launching a Jupyter notebook from an Anaconda environment (Python 3.6.8) on Windows 10 and when I do that the page that's displayed in my Chrome browser is totally blank.
The output in the console (git bash) window looks like this:
$ jupyter notebook object_detection_tutorial.ipynb
[I 13:18:13.500 NotebookApp] Serving notebooks from local directory: C:\home\git\object_detection_tensorflow\TensorFlow\models\research\object_detection
[I 13:18:13.500 NotebookApp] The Jupyter Notebook is running at:
[I 13:18:13.500 NotebookApp] http://localhost:8888/?token=bfb419ee35f8fd9800621e52dc8d73515990e2298148135b
[I 13:18:13.500 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:18:13.513 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/James%20Adams/AppData/Roaming/jupyter/runtime/nbserver-2808-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=bfb419ee35f8fd9800621e52dc8d73515990e2298148135b
If I copy and paste the URL listed above into the Chrome browser address bar I get a normal looking response in the console but the same blank page in the browser:
[I 13:21:17.840 NotebookApp] 302 GET /?token=bfb419ee35f8fd9800621e52dc8d73515990e2298148135b (::1) 0.99ms
I have tried a number of things with no different result so far:
clear the browser's cache and cookies
downgraded the notebook module to 5.7.4 (conda install notebook=5.7.4)
used a different browser (Firefox)
What else can I try to fix this?

Jupyter Notebook is not being opened in windows using Anaconda Prompt?

1) I tried to open Jupyter Notebook in Anaconda prompt.
Ananconda Prompt:
(C:\Users\sankarreddy\Anaconda3) C:\Users\sankarreddy>jupyter notebook
[I 21:24:52.854 NotebookApp] Serving notebooks from local directory: C:\Users\sankarreddy
[I 21:24:52.855 NotebookApp] 0 active kernels
[I 21:24:52.856 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=fb39c20421e31cc66fddfd4fc00c7f64b8003bc53b83f461
[I 21:24:52.856 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:24:52.868 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=fb39c20421e31cc66fddfd4fc00c7f64b8003bc53b83f461
2) My default browser is Google chrome and every time when I try to open the Jupyter notebook, the following is the result.
Result in the Browser(Google Chrome):
ERROR: Gateway Timeout
While trying to retrieve the URL http://localhost:8888/tree?token=4f3786890eceb91493af9bd6f4b07ae1ac6888c6172bbfca:
Connection refused
Your cache administrator is webmaster.
Generated Sun, 23 Jul 2017 14:01:21 GMT by 103.217.212.129 (Mikrotik HttpProxy)
3) I interrupted the process using 'Ctrl+C'.. it displays as follows.
[I 19:43:23.364 NotebookApp] Interrupted...
[I 19:43:23.365 NotebookApp] Shutting down kernels
I have googled about this issue, but had very little help which is of no use.
It seems like you're trying to open Jupyter Notebook in port 8888 as stated by the error message While trying to retrieve the URL http://localhost:8888/tree?token=4f3786890eceb91493af9bd6f4b07ae1ac6888c6172bbfca
But, when running Jupyter Notebook, there was an error message stating something else is running in port 8888 and it started the server in the next available port, which is 8889: [I 19:26:39.239 NotebookApp] The Jupyter Notebook is running at: http://localhos t:8889/?token=86664b50ba28f3bd3431554bc84d60d8bf4f3bf4209a4ecf
I'm not sure how to identify what is running on 8888, but you should definitely access your Jupyter Notebook on localhost:8889 .

How to use docker to connect with jupyter notebooks

I try to connect to jupyter notebooks from macos terminal, but when I use
python run_docker_jupyter.py
it returns me
Projects/data_science_course/mlcourse_open:/notebooks -w /notebooks festline/mlcourse_open jupyter
Command: jupyter
[I 14:12:55.078 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 14:12:55.101 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[W 14:12:55.101 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.
[I 14:12:55.113 NotebookApp] Serving notebooks from local directory: /notebooks
[I 14:12:55.114 NotebookApp] 0 active kernels
[I 14:12:55.114 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:4545/
[I 14:12:55.114 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
And I need to connect with local host, but after some command it returns me nothing. Or if I use docker ps or another docker command, it only prints this command in the terminal with sign [ before the command and after that it turn to next string. And that's all.
It's the first time I use docker, so I will be grateful for the help.
Try to use test your python first, e.t. try to run something as simple as:
python -c "print('test')"
you should have you "test" string as output.
Then try to check your docker:
issue:
$docker-machine ssh
if everything is okay you will be able to run
$docker ls
There is a known issue with kernel crashes that can be fixed by using Tini, I have attached links to a couple of gists that work very well.
Docker-compose yaml and Dockerfile

Categories