not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

382 lines
16 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. \documentclass[pdftex,12pt]{artikel3}
  2. % Compile with: pdflatex
  3. % Settings for source listings.
  4. \usepackage[dvips,letterpaper,margin=1.1in]{geometry}
  5. \usepackage{listings,graphicx}
  6. \usepackage{url} % usage \href{}{}
  7. \usepackage{xcolor}
  8. %% \usepackage{soul}
  9. %% \usepackage{lipsum}
  10. \usepackage{mathtools}
  11. % \newcommand{\myul}[2][black]{\setulcolor{#1}\ul{#2}\setulcolor{black}}
  12. \usepackage{array}
  13. %% \usepackage{multirow}
  14. \usepackage{alltt}
  15. \usepackage{pifont}
  16. \usepackage{courier}
  17. \usepackage{fancyvrb}
  18. \usepackage{enumitem}
  19. \usepackage[hidelinks]{hyperref} % hide links in hyperref text
  20. \usepackage{cleveref} % nice table/figure refs. put after hyperref
  21. % sample stuff for tables and figs
  22. %\usepackage{blindtext}
  23. \usepackage{makeidx} % for makeindex
  24. \usepackage{tocloft} % for nicely formatted toc, tof, lof
  25. \usepackage{booktabs,longtable,tabu}
  26. \usepackage[utf8]{inputenc}
  27. \usepackage[T1]{fontenc}
  28. \usepackage{imakeidx}
  29. \usepackage{listings}
  30. \usepackage{color}
  31. \definecolor{dkgreen}{rgb}{0,0.6,0}
  32. \definecolor{gray}{rgb}{0.5,0.5,0.5}
  33. \definecolor{mauve}{rgb}{0.58,0,0.82}
  34. \lstset{frame=tb,
  35. language=Java,
  36. aboveskip=3mm,
  37. belowskip=3mm,
  38. showstringspaces=false,
  39. columns=flexible,
  40. basicstyle={\small\ttfamily},
  41. numbers=none,
  42. numberstyle=\tiny\color{gray},
  43. keywordstyle=\color{blue},
  44. commentstyle=\color{dkgreen},
  45. stringstyle=\color{mauve},
  46. breaklines=true,
  47. breakatwhitespace=true,
  48. tabsize=3
  49. }
  50. %% preamble
  51. % the tabfigref command outputs a table or figure reference
  52. % with pattern: "Figure N, The Caption," or "Table N, The Caption,"
  53. % Note: output has a trailing comma(,) for phrasing.
  54. \newcommand{\tabfigref}[1]{\autoref{#1}, \nameref{#1},}
  55. \setcounter{tocdepth}{3}
  56. \makeindex[columns=2, title=Index, intoc]
  57. \lstset{tabsize=4,language=Python,showstringspaces=false}
  58. \title{
  59. \begin{center}
  60. \huge{Jupyter Notebook User Document} \\
  61. \huge{Progessional Communications}\\
  62. \newline
  63. \huge{Team: Dolphins}\\
  64. \end{center}
  65. \\
  66. \\
  67. \\
  68. \\
  69. \author{} % \author{Jeffery B. Russell} \\
  70. % \author{Dan Moore}
  71. \date{} % \date{Febuary 20, 2020}
  72. }
  73. %% document starts
  74. \begin{document}
  75. \maketitle
  76. \begin{center}
  77. \author{Jeffery B. Russell},
  78. \author{Daniel Moore},
  79. \author{Louden Yandow}
  80. \date{March 2, 2020}
  81. \end{center}
  82. \newpage
  83. \tableofcontents
  84. \addtocontents{toc}{~\hfill\textbf{Page}\par}
  85. \addcontentsline{toc}{section}{\listfigurename} % include lists of figs
  86. \newpage
  87. \listoffigures
  88. \addtocontents{lof}{~\hfill\textbf{Page}\par}
  89. \newpage
  90. \section{Introduction}
  91. Jupyter \index{jupyter} is an open-source web-based notebook tool that you can use as your development environment.
  92. A coding notebook enables you to intermix markdown and code blocks that you can execute in a single document. This is heavily used in education and research fields because it makes writing reports easy and reproducible. With Jupyter you can create content that has live code, equations, visualizations and explanatory text. Jupyter is a
  93. Jupyter Lab extends the basic Jypyter notebook functionality and provides you a full web environment to work in. Using this interface you can open terminals, manage files, and even tile multiple editors.
  94. Applications of Jupyter Jab:
  95. \begin{itemize}
  96. \item Quick experimentation
  97. \item Writing a report
  98. \item Sharing code snippets for education
  99. \item Generating graphics
  100. \end{itemize}
  101. This document goes over the basic installation and usage of Jupyter Lab for personal development.
  102. In the advanced usage section we go over how to use Jupyter\index{jupyter} on a remote server.
  103. \section{Installation}
  104. Full installation instructions can be found on the Jupyter website. \footnote{\url{ https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html}} This user document goes over how to install Jupyter Lab.
  105. \subsection{Prerequisites}
  106. In order to install Jupyter Lab, you must have Python installed. Your version of Python \textbf{must be 3.3 or greater}.
  107. As part of having Python, you will also need to have PIP. Although PIP usually comes with your Python installation, there are some exceptions on Linux where you have to install the two seperately.
  108. Go to the Python\index{python} website\footnote{\url{ https://www.python.org/downloads/}} to download the latest version of Python.
  109. We highly recommend you take the time to install \href{https://docs.conda.io/projects/conda/en/latest/user-guide/install/}{Conda}\index{anaconda} because it will be helpful later on with some of the more advanced features of Jupyter as well as machine learning in Python.
  110. You should also have either Firefox, Chrome, or Safari because these are the only browsers Jupyter\index{jupyter} is currently known to work well with.
  111. \subsection{Installation on Linux}
  112. There are two ways of installing Jupyter on Linux.\\
  113. \\
  114. Using pip\index{pip}, the command is:.\\
  115. \begin{lstlisting}
  116. $pip install jupyterlab
  117. \end{lstlisting}
  118. \\
  119. Using conda, the command is:
  120. \begin{lstlisting}
  121. $conda install -c conda-forge jupyterlab
  122. \end{lstlisting}
  123. \subsection{Installation on Windows}
  124. Installation on Windows is the same as installation on Linux except that you must also use the flag to install at a user level if you don't want to run the command as an administrator:
  125. \begin{lstlisting}
  126. >pip install jupyterlab --user
  127. \end{lstlisting}
  128. \section{Usage}
  129. To run Jupyter Lab, open your computer's command terminal and enter the following command. This will open Jupyter Lab in your default web browser.
  130. \begin{lstlisting}
  131. jupyter lab
  132. \end{lstlisting}
  133. Figure 1 is what you will see upon first running Jupyter Lab. Otherwise, it will open to the most recent notebook you were working on.
  134. \begin{figure}[h!]
  135. \centering
  136. \includegraphics[width=65mm]{launcher.png}
  137. \caption{Default Jupyter Lab launcher}
  138. \label{fig:jupyterlablauncher}
  139. \end{figure}
  140. \subsection{Navigation}
  141. Once Jupyter Lab is running, you will see on the left side of the window a column of icons.
  142. Each icon will open a different panel to the right when clicked.
  143. \begin{itemize}
  144. \item File Browser (folder icon): displays a file browser for the user to open, move, or delete their files.
  145. \item Running Terminals and Kernels (square stop button): shows the user all currently active terminal and kernel sessions.
  146. \item Commands (palette icon): allows the user to enter various commands into Jupyter Lab.
  147. \item Notebook Tools (wrench icon): shows various options for the user's current notebook.
  148. \item Open Tabs (a tabbed window icon): lists all currently open tabs in Jupyter Lab.
  149. \end{itemize}
  150. Additionally, the top toolbar contains the following different drop-down menus: "File", "Edit", "View", "Run", "Kernel", "Tabs", "Settings", and "Help".
  151. \subsection{Creating a Notebook}
  152. To create a notebook from the launcher (figure 1), click on the Python 3 icon under the orange notebook symbol. Alternatively, if you don't have the launcher open, you can click on "File" in the toolbar, click "New", and finally click "Notebook".
  153. This will open an empty, untitled notebook. If you right click on the tab above, or on the name of your notebook in the "Open Tabs" panel on the left, you can rename your notebook.
  154. \subsection{Running a Notebook}
  155. With a notebook open, you can start writing in the editor-- the big empty area on the right half of the screen. Just above the editor, you will find the icon to save the open notebook.
  156. There are also a number of icons that directly relate to the cells you are modifying. A cell may contain either Python\index{python} code, markdown\index{markdown}, or raw text. You can change what type of text a cell is by clicking on the drop-down menu just above the editor that will say either "Code", "Markdown", or "Raw".
  157. The icons above the editor, from left to right, do the following things:
  158. \begin{itemize}
  159. \item Add a cell after the currently selected cell.
  160. \item Cut the currently selected cell.
  161. \item Copy the selected cell.
  162. \item Paste the cell from the clipboard.
  163. \item Run the selected cells and advance to the next cell.
  164. \item Interrupt the kernel.
  165. \item Restart the kernel.
  166. \end{itemize}
  167. The following example shows how to write code, run code, and insert raw text into the notebook. First, write some python code and click the "Run selected cells and advance" button (circled in red in the figure below). Our output is shown in figure 2. When a notebooks runs all cells, it executes top to bottom.
  168. \begin{figure}[h!]
  169. \centering
  170. \includegraphics[width=15cm]{code_before_running.png}
  171. \caption{Code before being run}
  172. \label{fig:codebeforerunning}
  173. \end{figure}
  174. \begin{figure}[h!]
  175. \centering
  176. \includegraphics[width=15cm]{code_after_running.png}
  177. \caption{Code after being run}
  178. \label{fig:codeafterrunning}
  179. \end{figure}
  180. You can also insert raw text into your document, as shown below.
  181. To do this, change the drop-down menu from "Code" (or "Markdown") to "Raw", and type what you want in the cell.
  182. This is demonstrated in figure 4.
  183. \begin{figure}[h!]
  184. \centering
  185. \includegraphics[width=15cm]{raw_text_example.png}
  186. \caption{Example of raw text}
  187. \label{fig:rawtextexample}
  188. \end{figure}
  189. \subsection{Exporting Notebooks}
  190. In order to export the document, click the \textbf{File} tab, mouse down to \textbf{Export Notebook As...} and then click a desired format-- Jupyter supports a lot of format types.
  191. The most popular export formats are PDF, Markdown\index{markdown}, and HTML.
  192. \subsection{Customization}
  193. In general, customization of Jupyter easy.\\
  194. \\
  195. To change the Jupyter theme, go to the "Settings" tab and drop down to Jupyter\index{jupyter} Lab Theme. This will allow you to change from light to dark mode as well as the font sizes for the code, content and UI.\\
  196. \\
  197. Scrolling down the rest of the settings you see many other things that can be customized.\\
  198. \\
  199. Advanced settings allows you to customize many aspects of Jupyter Lab such as keyboard shortcuts, terminal settings, and a myriad of others. Figure 5 shows the configuration menu for Jupyter\index{jupyter} Lab.
  200. \begin{figure}[h!]
  201. \centering
  202. \includegraphics[width=15cm]{settings.jpg}
  203. \caption{Settings window}
  204. \label{fig:configuration}
  205. \end{figure}
  206. \section{Advanced Usage}
  207. This section goes over how to use multiple programming languages in Jupyter\index{jupyter} and how to connect to your Jupyter Lab instance remotely.
  208. \subsection{Multiple Kernels}
  209. Adding a Kernel in Jupyter enables you to program with another programming language, such as R\index{r} or Scala\index{scala}.
  210. Up to this point, we have been working with the Python kernel\index{python} which enables you to make python notebooks. The ability to use multiple kernels is useful for education and having cohesion within one IDE\index{IDE}.
  211. You can view a complete list of kernels can be found on Jupyter's Github wiki.\footnote{\url{https://github.com/jupyter/jupyter/wiki/Jupyter-kernels}}
  212. \begin{figure}[h!]
  213. \centering
  214. \includegraphics[width=50mm]{exampleKernels.PNG}
  215. \caption{Example of multiple kernels installed}
  216. \label{fig:multKernels}
  217. \end{figure}
  218. Figure 6 shows an example of what your launcher would look like with multiple kernels installed.
  219. The most common way to install a kernel is by using the Anaconda\index{anaconda} prompt -- pip\index{pip} support is limited here.
  220. Once you start adding multiple kernels, it is best if you start running Jupyter Lab through Docker\index{docker} because it would make porting it to another computer easier. A popular Docker Jupyter lab instance with Scala, Python, and R can be found on Jupyter's Docker hub profile\footnote{\url{https://hub.docker.com/u/jupyter/}}.
  221. \subsection{Remote Connection}
  222. If you have a firewall, Jupyter Lab will only be reachable on your
  223. local machine at "localhost:8888".
  224. However, it is possible to connect to Jupyter Lab from remote computers.
  225. Remote access is helpful since it enables multiple people to connect to the same Jupyter instance. This would also save you resources on your local machine so you can program on a lightweight chrome-book that would not be able to run a full IDE\index{IDE} like Pycharm\index{pycharm}.
  226. The first step to enable remote host would be to set a password that you can connect to the notebook using. You can set a password that you use to log into the website by executing the following command in a terminal:
  227. \begin{lstlisting}
  228. jupyter notebook password
  229. \end{lstlisting}
  230. The second step would be to launch the Jupyter Lab instance in a headless environment -- it never launches a web browser.
  231. A headless environments means that you never launch a GUI and it operates solely as a console application.
  232. \begin{lstlisting}
  233. jupyter lab --no-browser --port=6000
  234. \end{lstlisting}
  235. The final step is to connect to the Jupyter Lab instance from your
  236. remote computer.
  237. The easiest way to do this is via a local port forward in SSH\index{ssh}.
  238. The command at listing 1 forwards all of the traffic from your local machine to a specific port on a remote computer over a SSH connection.
  239. The main benefit of SSH is that all the traffic over the connection is encrypted.
  240. Figure 7 shows an overview of what the network architecture looks like.
  241. \newpage
  242. \begin{lstlisting}[caption=SSH command for local port forwarding]
  243. ssh -L 6000:localhost:6000 user@remote-host
  244. \end{lstlisting}
  245. \begin{figure}[h!]
  246. \centering
  247. \includegraphics[width=15cm]{remoteJupyter.png}
  248. \caption{Network Overview}
  249. \label{fig:jupyter_server}
  250. \end{figure}
  251. After you execute the command above on your remote computer, you
  252. will be able to access your Jupyter Lab instance at "localhost:6000" even though it is only running on the remote computer at port 6000.
  253. \newpage
  254. \section{Glossary}
  255. \begin{itemize}[label={}]
  256. \item {\bf Anaconda}: Anaconda is a package manager for the R and Python languages aimed towards data science" \footnote{\url{ https://www.anaconda.com}}.\index{anaconda}\\
  257. \item {\bf IDE}: Interactive Development Environment-- some popular IDEs are Pycharm, Netbeans, and Visual Studio.\index{IDE}\\
  258. \item {\bf Jupyter}: Nonprofit organization created to "develop open-source software, open-standards, and services for interactive computing across dozens of programming languages" \footnote{\url{ https://jupyter.org/}}.\index{jupyter}\\
  259. \item {\bf JVM}: Java Virtual Machine\index{ssh}\\
  260. \item {\bf Markdown(MD)}: Lightweight markup-language -- used to define layout and style for a document \footnote{\url{https://en.wikipedia.org/wiki/Markdown}}.\index{markdown}\\
  261. \item {\bf pip}: Tool for installing and managing python packages \footnote{\url{ https://pypi.org/project/pip/}}.\index{pip}\\
  262. \item {\bf Pycharm}: A popular versatile Python IDE developed by \href{https://www.jetbrains.com/}{Jetbrains}.\index{IDE}\\
  263. \item {\bf Python}: High-level interpreted, general purpose programming language \footnote{\url{ https://www.python.org/}}.\index{python}\\
  264. \item {\bf R}: Programming language for statistical computing and graphics \footnote{\url{ https://www.r-project.org/}}.\index{r}\\
  265. \item {\bf Scala}: General purpose functional programming language that runs on the JVM \footnote{\url{ https://scala-lang.org/}}.\index{scala}\\
  266. \item {\bf SSH}: Secure Socket Shell -- used in connecting to a remote computer over a encrypted channel.\index{ssh}\\
  267. \end{itemize}
  268. \newpage
  269. \section{References}
  270. \begin{enumerate}
  271. \item
  272. \url{https://jupyter.org/}
  273. \item
  274. \url{https://www.python.org/}
  275. \item
  276. \url{https://en.wikipedia.org/wiki/Markdown}
  277. \item
  278. \url{https://pypi.org/project/pip/}
  279. \item
  280. \url{https://scala-lang.org/}
  281. \item
  282. \url{https://www.r-project.org/}
  283. \item
  284. \url{https://www.jetbrains.com/}
  285. \end{enumerate}
  286. \newpage
  287. %\section{Index}
  288. \printindex
  289. % outputs its own heading, which does not match the sections
  290. \end{document}