Monday, July 29, 2019

Python - Opening Ipython Notebooks in Ubuntu

To be able to open Ipython Notebooks. We must install 2 modules using pip3.

  1. ipython
  2. notebook


Summary Installation Commands:

$ pip3 install ipython
$ pip3 install notebook

Once we install these modules, we can open an ipython notebook using the command:

$ ipython notebook MyNotebook-01.ipynb



Detailed Installation Commands:

Step 1: Install ipython

$ pip3 install ipython
Collecting ipython
  Downloading https://files.pythonhosted.org/packages/f6/c4/a79582814bdfe92bfca4d286a729304ffdf13f5135132cfcaea13cf1b2b3/ipython-7.7.0-py3-none-any.whl (774kB)
    100% |████████████████████████████████| 778kB 1.6MB/s 
Collecting pickleshare (from ipython)
  Downloading https://files.pythonhosted.org/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl
Collecting pexpect; sys_platform != "win32" (from ipython)
  Downloading https://files.pythonhosted.org/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 6.1MB/s 
Collecting setuptools>=18.5 (from ipython)
  Using cached https://files.pythonhosted.org/packages/ec/51/f45cea425fd5cb0b0380f5b0f048ebc1da5b417e48d304838c02d6288a1e/setuptools-41.0.1-py2.py3-none-any.whl
Collecting pygments (from ipython)
  Downloading https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl (883kB)
    100% |████████████████████████████████| 890kB 1.4MB/s 
Collecting backcall (from ipython)
  Downloading https://files.pythonhosted.org/packages/84/71/c8ca4f5bb1e08401b916c68003acf0a0655df935d74d93bf3f3364b310e0/backcall-0.1.0.tar.gz
Collecting decorator (from ipython)
  Downloading https://files.pythonhosted.org/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Collecting traitlets>=4.2 (from ipython)
  Downloading https://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl (74kB)
    100% |████████████████████████████████| 81kB 7.1MB/s 
Collecting jedi>=0.10 (from ipython)
  Downloading https://files.pythonhosted.org/packages/4e/06/e906725a5b3ad7996bbdbfe9958aab75db64ef84bbaabefe47574de58865/jedi-0.14.1-py2.py3-none-any.whl (1.0MB)
    100% |████████████████████████████████| 1.0MB 1.3MB/s 
Collecting prompt-toolkit<2.1.0,>=2.0.0 (from ipython)
  Downloading https://files.pythonhosted.org/packages/f7/a7/9b1dd14ef45345f186ef69d175bdd2491c40ab1dfa4b2b3e4352df719ed7/prompt_toolkit-2.0.9-py3-none-any.whl (337kB)
    100% |████████████████████████████████| 337kB 1.3MB/s 
Collecting ptyprocess>=0.5 (from pexpect; sys_platform != "win32"->ipython)
  Downloading https://files.pythonhosted.org/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl
Collecting six (from traitlets>=4.2->ipython)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting ipython-genutils (from traitlets>=4.2->ipython)
  Downloading https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting parso>=0.5.0 (from jedi>=0.10->ipython)
  Downloading https://files.pythonhosted.org/packages/a3/bd/bf4e5bd01d79906e5b945a7af033154da49fd2b0d5b5c705a21330323305/parso-0.5.1-py2.py3-none-any.whl (95kB)
    100% |████████████████████████████████| 102kB 2.0MB/s 
Collecting wcwidth (from prompt-toolkit<2.1.0,>=2.0.0->ipython)
  Downloading https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Building wheels for collected packages: backcall
  Running setup.py bdist_wheel for backcall ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/98/b0/dd/29e28ff615af3dda4c67cab719dd51357597eabff926976b45
Successfully built backcall
Installing collected packages: pickleshare, ptyprocess, pexpect, setuptools, pygments, backcall, decorator, six, ipython-genutils, traitlets, parso, jedi, wcwidth, prompt-toolkit, ipython
Successfully installed backcall-0.1.0 decorator-4.4.0 ipython-7.7.0 ipython-genutils-0.2.0 jedi-0.14.1 parso-0.5.1 pexpect-4.7.0 pickleshare-0.7.5 prompt-toolkit-2.0.9 ptyprocess-0.6.0 pygments-2.4.2 setuptools-41.0.1 six-1.12.0 traitlets-4.3.2 wcwidth-0.1.7
$


Step 2: Install Notebook:

$ pip3 install notebook
Collecting notebook
  Downloading https://files.pythonhosted.org/packages/4e/b6/a6189ca7146482d93c912dbe6c65db0f264c1c88f707feea3683caa6c1f8/notebook-6.0.0-py3-none-any.whl (9.0MB)
    100% |████████████████████████████████| 9.0MB 164kB/s 
Collecting jupyter-client>=5.3.1 (from notebook)
  Downloading https://files.pythonhosted.org/packages/af/4c/bf613864ae0644e2ac7d4a40bd209c40c8c71e3dc88d5f1d0aa92a68e716/jupyter_client-5.3.1-py2.py3-none-any.whl (91kB)
    100% |████████████████████████████████| 92kB 6.6MB/s 
Collecting Send2Trash (from notebook)
  Downloading https://files.pythonhosted.org/packages/49/46/c3dc27481d1cc57b9385aff41c474ceb7714f7935b1247194adae45db714/Send2Trash-1.5.0-py3-none-any.whl
Collecting prometheus-client (from notebook)
  Downloading https://files.pythonhosted.org/packages/b3/23/41a5a24b502d35a4ad50a5bb7202a5e1d9a0364d0c12f56db3dbf7aca76d/prometheus_client-0.7.1.tar.gz
Collecting traitlets>=4.2.1 (from notebook)
  Using cached https://files.pythonhosted.org/packages/93/d6/abcb22de61d78e2fc3959c964628a5771e47e7cc60d53e9342e21ed6cc9a/traitlets-4.3.2-py2.py3-none-any.whl
Collecting ipykernel (from notebook)
  Downloading https://files.pythonhosted.org/packages/a0/35/dd97fbb48d4e6b5ae97307497e31e46691adc2feedb6279d29fc1c8ad9c1/ipykernel-5.1.1-py3-none-any.whl (114kB)
    100% |████████████████████████████████| 122kB 8.9MB/s 
Collecting pyzmq>=17 (from notebook)
  Downloading https://files.pythonhosted.org/packages/92/92/ea8f20560d5f1d0c6eb3c7c67ca72abfb97307f4e6494fc05cc7c37904cf/pyzmq-18.0.2-cp36-cp36m-manylinux1_x86_64.whl (1.1MB)
    100% |████████████████████████████████| 1.1MB 1.2MB/s 
Collecting nbconvert (from notebook)
  Downloading https://files.pythonhosted.org/packages/35/e7/f46c9d65f149271e47fca6ab084ef5c6e4cb1870f4c5cce6690feac55231/nbconvert-5.5.0-py2.py3-none-any.whl (447kB)
    100% |████████████████████████████████| 450kB 2.5MB/s 
Collecting ipython-genutils (from notebook)
  Using cached https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting jupyter-core>=4.4.0 (from notebook)
  Downloading https://files.pythonhosted.org/packages/e6/25/6ffb0f6e57fa6ef5d2f814377133b361b42a6dd39105f4885a4f1666c2c3/jupyter_core-4.5.0-py2.py3-none-any.whl (78kB)
    100% |████████████████████████████████| 81kB 6.8MB/s 
Collecting terminado>=0.8.1 (from notebook)
  Downloading https://files.pythonhosted.org/packages/a7/56/80ea7fa66565fa75ae21ce0c16bc90067530e5d15e48854afcc86585a391/terminado-0.8.2-py2.py3-none-any.whl
Collecting jinja2 (from notebook)
  Using cached https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl
Collecting nbformat (from notebook)
  Downloading https://files.pythonhosted.org/packages/da/27/9a654d2b6cc1eaa517d1c5a4405166c7f6d72f04f6e7eea41855fe808a46/nbformat-4.4.0-py2.py3-none-any.whl (155kB)
    100% |████████████████████████████████| 163kB 5.4MB/s 
Collecting tornado>=5.0 (from notebook)
  Downloading https://files.pythonhosted.org/packages/30/78/2d2823598496127b21423baffaa186b668f73cd91887fcef78b6eade136b/tornado-6.0.3.tar.gz (482kB)
    100% |████████████████████████████████| 491kB 2.4MB/s 
Collecting python-dateutil>=2.1 (from jupyter-client>=5.3.1->notebook)
  Using cached https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl
Collecting decorator (from traitlets>=4.2.1->notebook)
  Using cached https://files.pythonhosted.org/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Collecting six (from traitlets>=4.2.1->notebook)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting ipython>=5.0.0 (from ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/f6/c4/a79582814bdfe92bfca4d286a729304ffdf13f5135132cfcaea13cf1b2b3/ipython-7.7.0-py3-none-any.whl
Collecting entrypoints>=0.2.2 (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/ac/c6/44694103f8c221443ee6b0041f69e2740d89a25641e62fb4f2ee568f2f9c/entrypoints-0.3-py2.py3-none-any.whl
Collecting defusedxml (from nbconvert->notebook)
  Using cached https://files.pythonhosted.org/packages/06/74/9b387472866358ebc08732de3da6dc48e44b0aacd2ddaa5cb85ab7e986a2/defusedxml-0.6.0-py2.py3-none-any.whl
Collecting pygments (from nbconvert->notebook)
  Using cached https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl
Collecting bleach (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/ab/05/27e1466475e816d3001efb6e0a85a819be17411420494a1e602c36f8299d/bleach-3.1.0-py2.py3-none-any.whl (157kB)
    100% |████████████████████████████████| 163kB 4.6MB/s 
Collecting testpath (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/be/a4/162f9ebb6489421fe46dcca2ae420369edfee4b563c668d93cb4605d12ba/testpath-0.4.2-py2.py3-none-any.whl (163kB)
    100% |████████████████████████████████| 163kB 3.8MB/s 
Collecting pandocfilters>=1.4.1 (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/4c/ea/236e2584af67bb6df960832731a6e5325fd4441de001767da328c33368ce/pandocfilters-1.4.2.tar.gz
Collecting mistune>=0.8.1 (from nbconvert->notebook)
  Downloading https://files.pythonhosted.org/packages/09/ec/4b43dae793655b7d8a25f76119624350b4d65eb663459eb9603d7f1f0345/mistune-0.8.4-py2.py3-none-any.whl
Collecting ptyprocess; os_name != "nt" (from terminado>=0.8.1->notebook)
  Using cached https://files.pythonhosted.org/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2->notebook)
  Using cached https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat->notebook)
  Downloading https://files.pythonhosted.org/packages/aa/69/df679dfbdd051568b53c38ec8152a3ab6bc533434fc7ed11ab034bf5e82f/jsonschema-3.0.1-py2.py3-none-any.whl (54kB)
    100% |████████████████████████████████| 61kB 7.0MB/s 
Collecting prompt-toolkit<2.1.0,>=2.0.0 (from ipython>=5.0.0->ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/f7/a7/9b1dd14ef45345f186ef69d175bdd2491c40ab1dfa4b2b3e4352df719ed7/prompt_toolkit-2.0.9-py3-none-any.whl
Collecting pickleshare (from ipython>=5.0.0->ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/9a/41/220f49aaea88bc6fa6cba8d05ecf24676326156c23b991e80b3f2fc24c77/pickleshare-0.7.5-py2.py3-none-any.whl
Collecting jedi>=0.10 (from ipython>=5.0.0->ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/4e/06/e906725a5b3ad7996bbdbfe9958aab75db64ef84bbaabefe47574de58865/jedi-0.14.1-py2.py3-none-any.whl
Collecting pexpect; sys_platform != "win32" (from ipython>=5.0.0->ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl
Collecting setuptools>=18.5 (from ipython>=5.0.0->ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/ec/51/f45cea425fd5cb0b0380f5b0f048ebc1da5b417e48d304838c02d6288a1e/setuptools-41.0.1-py2.py3-none-any.whl
Collecting backcall (from ipython>=5.0.0->ipykernel->notebook)
Collecting webencodings (from bleach->nbconvert->notebook)
  Using cached https://files.pythonhosted.org/packages/f4/24/2a3e3df732393fed8b3ebf2ec078f05546de641fe1b667ee316ec1dcf3b7/webencodings-0.5.1-py2.py3-none-any.whl
Collecting pyrsistent>=0.14.0 (from jsonschema!=2.5.0,>=2.4->nbformat->notebook)
  Downloading https://files.pythonhosted.org/packages/b9/66/b2638d96a2d128b168d0dba60fdc77b7800a9b4a5340cefcc5fc4eae6295/pyrsistent-0.15.4.tar.gz (107kB)
    100% |████████████████████████████████| 112kB 6.5MB/s 
Collecting attrs>=17.4.0 (from jsonschema!=2.5.0,>=2.4->nbformat->notebook)
  Downloading https://files.pythonhosted.org/packages/23/96/d828354fa2dbdf216eaa7b7de0db692f12c234f7ef888cc14980ef40d1d2/attrs-19.1.0-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<2.1.0,>=2.0.0->ipython>=5.0.0->ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting parso>=0.5.0 (from jedi>=0.10->ipython>=5.0.0->ipykernel->notebook)
  Using cached https://files.pythonhosted.org/packages/a3/bd/bf4e5bd01d79906e5b945a7af033154da49fd2b0d5b5c705a21330323305/parso-0.5.1-py2.py3-none-any.whl
Building wheels for collected packages: prometheus-client, tornado, pandocfilters, pyrsistent
  Running setup.py bdist_wheel for prometheus-client ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/1c/54/34/fd47cd9b308826cc4292b54449c1899a30251ef3b506bc91ea
  Running setup.py bdist_wheel for tornado ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/84/bf/40/2f6ef700f48401ca40e5e3dd7d0e3c0a90e064897b7fe5fc08
  Running setup.py bdist_wheel for pandocfilters ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/39/01/56/f1b08a6275acc59e846fa4c1e1b65dbc1919f20157d9e66c20
  Running setup.py bdist_wheel for pyrsistent ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/bb/46/00/6d471ef0b813e3621f0abe6cb723c20d529d39a061de3f7c51
Successfully built prometheus-client tornado pandocfilters pyrsistent
Installing collected packages: pyzmq, tornado, decorator, six, ipython-genutils, traitlets, jupyter-core, python-dateutil, jupyter-client, Send2Trash, prometheus-client, wcwidth, prompt-toolkit, pickleshare, parso, jedi, pygments, ptyprocess, pexpect, setuptools, backcall, ipython, ipykernel, pyrsistent, attrs, jsonschema, nbformat, entrypoints, MarkupSafe, jinja2, defusedxml, webencodings, bleach, testpath, pandocfilters, mistune, nbconvert, terminado, notebook
Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 attrs-19.1.0 backcall-0.1.0 bleach-3.1.0 decorator-4.4.0 defusedxml-0.6.0 entrypoints-0.3 ipykernel-5.1.1 ipython-7.7.0 ipython-genutils-0.2.0 jedi-0.14.1 jinja2-2.10.1 jsonschema-3.0.1 jupyter-client-5.3.1 jupyter-core-4.5.0 mistune-0.8.4 nbconvert-5.5.0 nbformat-4.4.0 notebook-6.0.0 pandocfilters-1.4.2 parso-0.5.1 pexpect-4.7.0 pickleshare-0.7.5 prometheus-client-0.7.1 prompt-toolkit-2.0.9 ptyprocess-0.6.0 pygments-2.4.2 pyrsistent-0.15.4 python-dateutil-2.8.0 pyzmq-18.0.2 setuptools-41.0.1 six-1.12.0 terminado-0.8.2 testpath-0.4.2 tornado-6.0.3 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1
$

Now, let us open out Ipython Notebook:


$ ipython notebook My-Notebook-01.ipynb
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[I 11:00:41.831 NotebookApp] Writing notebook server cookie secret to /home/ubuntu/.local/share/jupyter/runtime/notebook_cookie_secret
[I 11:00:41.854 NotebookApp] Serving notebooks from local directory: /home/ubuntu/Documents/my-files-mooc/DS-Intro-Michigan/Course-01
[I 11:00:41.854 NotebookApp] The Jupyter Notebook is running at:
[I 11:00:41.854 NotebookApp] http://localhost:8888/?token=515a6aad1725091442d8a3060d2e07f2cbcc7888e8f79080
[I 11:00:41.854 NotebookApp]  or http://127.0.0.1:8888/?token=515a6aad1725091442d8a3060d2e07f2cbcc7888e8f79080
[I 11:00:41.854 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 11:00:41.860 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/ubuntu/.local/share/jupyter/runtime/nbserver-6937-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=515a6aad1725091442d8a3060d2e07f2cbcc7888e8f79080
     or http://127.0.0.1:8888/?token=515a6aad1725091442d8a3060d2e07f2cbcc7888e8f79080
Opening in existing browser session.
[E 11:00:43.502 NotebookApp] Could not open static file ''
[W 11:00:43.778 NotebookApp] 404 GET /static/components/react/react-dom.production.min.js (127.0.0.1) 8.66ms referer=http://localhost:8888/notebooks/week-02-Assignment-2.ipynb?token=515a6aad1725091442d8a3060d2e07f2cbcc7888e8f79080
[I 11:00:45.545 NotebookApp] Writing notebook-signing key to /home/ubuntu/.local/share/jupyter/notebook_secret
[W 11:00:45.549 NotebookApp] Notebook week-02-Assignment-2.ipynb is not trusted
[W 11:00:45.569 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20190729110041 (127.0.0.1) 1017.94ms referer=http://localhost:8888/notebooks/week-02-Assignment-2.ipynb
[I 11:00:46.862 NotebookApp] Kernel started: ac83c589-65d2-48a5-89f6-ce330f81bdfd
[I 11:00:47.679 NotebookApp] Adapting from protocol version 5.1 (kernel ac83c589-65d2-48a5-89f6-ce330f81bdfd) to 5.3 (client).
[I 11:02:06.999 NotebookApp] Starting buffering for ac83c589-65d2-48a5-89f6-ce330f81bdfd:351843f1bd364e348e9980cff4586dee
^C[I 11:05:58.555 NotebookApp] interrupted
Serving notebooks from local directory: /home/ubuntu/Documents/
1 active kernel
The Jupyter Notebook is running at:
http://localhost:8888/?token=515a6aad1725091442d8a3060d2e07f2cbcc7888e8f79080
 or http://127.0.0.1:8888/?token=515a6aad1725091442d8a3060d2e07f2cbcc7888e8f79080



Success!