{"id":148244,"date":"2023-10-16T11:33:56","date_gmt":"2023-10-16T15:33:56","guid":{"rendered":"http:\/\/www.bu.edu\/tech\/?page_id=148244"},"modified":"2024-04-22T21:11:00","modified_gmt":"2024-04-23T01:11:00","slug":"jupyter","status":"publish","type":"page","link":"https:\/\/www.bu.edu\/tech\/support\/research\/software-and-programming\/common-languages\/python\/python-editing\/jupyter\/","title":{"rendered":"Jupyter"},"content":{"rendered":"<p><a name=\"top\"><\/a><\/p>\n<div style=\"width:100%;\">\n<div style=\"float:right;width:49%;\"><img loading=\"lazy\" src=\"\/tech\/files\/2023\/12\/jupyter-e1702918056881.png\" alt=\"\" width=\"600\" height=\"419\" class=\"alignnone size-full wp-image-149633\" \/><\/div>\n<div style=\"float:none;\">\n<a href=\"https:\/\/jupyter.org\/\">Jupyter<\/a> can be deployed on the SCC in a number of ways. We recommend use of the Jupyter OnDemand Interactive App in combination with your preferred python environment (i.e. Python or Conda).<\/div>\n<p>&nbsp;<br \/>\n&nbsp;<br \/>\n<strong>Sections<\/strong><\/p>\n<ul>\n<li><a href=\"#app\">Jupyter OnDemand Interactive App<\/a><\/li>\n<li><a href=\"#desktop\">Jupyter OnDemand Desktop<\/a><\/li>\n<li><a href=\"#batch\">Jupyter Batch Jobs<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><a name=\"app\"><\/a><\/p>\n<h2>Jupyter OnDemand Interactive App<\/h2>\n<p>This is our recommended way to use and launch Jupyter. To launch Jupyter from SCC OnDemand, you will need to start a Jupyter Notebook Interactive App and load your preferred python environment (i.e. Python or Conda).<\/p>\n<ol type=\"1\">\n<li>Open a browser and login to <a href=\"https:\/\/scc-ondemand.bu.edu\">https:\/\/scc-ondemand.bu.edu<\/a> with your BU credentials.<\/li>\n<li>Click <b>Interactive Apps<\/b> &gt; <b>Jupyter Notebook<\/b>.<img loading=\"lazy\" src=\"\/tech\/files\/2023\/10\/jupyter_app-e1697496509775-636x369.png\" alt=\"\" width=\"636\" height=\"369\" class=\"alignnone size-medium wp-image-148298\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_app-e1697496509775-636x369.png 636w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_app-e1697496509775-1024x594.png 1024w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_app-e1697496509775-768x445.png 768w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_app-e1697496509775.png 1492w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/li>\n<li>Specify in the <b>Interface<\/b> field if you&#8217;d like to run a <code><span class=\"command\">notebook<\/span><\/code> or <code><span class=\"command\"> lab<\/span><\/code>. The default is <code><span class=\"command\">notebook<\/span><\/code>.<img loading=\"lazy\" src=\"\/tech\/files\/2023\/10\/jupyter_interface-636x171.png\" alt=\"\" width=\"636\" height=\"171\" class=\"alignnone size-medium wp-image-148300\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_interface-636x171.png 636w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_interface-768x207.png 768w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_interface.png 900w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/li>\n<li>Specify in the the <b>Working Directory<\/b> field the directory for your files. The default is your home directory.<img loading=\"lazy\" src=\"\/tech\/files\/2023\/10\/jupyter_workingdir-636x121.png\" alt=\"\" width=\"636\" height=\"121\" class=\"alignnone size-medium wp-image-148299\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_workingdir-636x121.png 636w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_workingdir-768x146.png 768w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_workingdir.png 844w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/li>\n<li>Click one of the Python environment options below for further instructions within that package manager:<br \/>\n<table border=\"0\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><input name=\"manager\" id=\"python1\" onclick=\"show_manager('python')\" value=\"python\" type=\"radio\" \/><br \/>\n<strong><label for=\"python1\">Python<\/label><\/strong><\/td>\n<td style=\"text-align: center;\"><input name=\"manager\" id=\"virtualenv1\" onclick=\"show_manager('virtualenv')\" value=\"virtualenv\" type=\"radio\" \/><br \/>\n<strong><label for=\"virtualenv1\">Python: virtualenv<\/label><\/strong><\/td>\n<td style=\"text-align: center;\"><input name=\"manager\" id=\"conda1\" onclick=\"show_manager('conda')\" value=\"conda\" type=\"radio\" \/><br \/>\n<strong><label for=\"conda1\">Miniconda: conda env<\/label><\/strong><\/td>\n<td style=\"text-align: center;\"><input name=\"manager\" id=\"select1\" onclick=\"show_manager('select')\" value=\"select\" type=\"radio\" \/><br \/>\n<strong><label for=\"select1\">hide<\/label><\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<div id=\"python\">\n&nbsp;<\/p>\n<ol type=\"A\">\n<li>On the Jupyter Notebook request page, specify your version of python in the <b>List of Modules to load<\/b> field. Then click <b>Launch<\/b> to submit the request.<br \/>\n<img loading=\"lazy\" src=\"\/tech\/files\/2023\/10\/jupyter_pyth-636x636.png\" alt=\"\" width=\"636\" height=\"636\" class=\"alignnone size-medium wp-image-148301\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_pyth-636x636.png 636w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_pyth-150x150.png 150w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_pyth-100x100.png 100w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_pyth.png 640w\" sizes=\"(max-width: 636px) 100vw, 636px\" \/><\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n<script type=\"text\/javascript\">\r\ndocument.getElementById('python').style.display = 'none';\r\n<\/script><\/p><\/div>\n<div id=\"virtualenv\">\n&nbsp;<\/p>\n<ol type=\"A\">\n<li>You will need to install <code><span class=\"command\">notebook<\/span><\/code> in your virtualenv for the kernel to be available in the OnDemand App. This is done with the following:\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">source<\/span> <span class=\"placeholder\">\/path\/to\/my_venv\/bin\/activate<\/span>\r\n<span class=\"prompt\">(my_venv) [rcs@scc1 ~]<\/span> <span class=\"command\">pip install notebook<\/span><\/code><\/pre>\n<\/li>\n<p>&nbsp;<\/p>\n<li>On the Jupyter Notebook request page, specify your version of python in the <b>List of Modules to load<\/b> field AND add the command to source your environment under the <b>Pre-Launch Commands (optional)<\/b> field. Then click <b>Launch<\/b> to submit the request.<br \/>\n<img loading=\"lazy\" src=\"\/tech\/files\/2023\/10\/jupyter_venv-e1697496487822-631x636.png\" alt=\"\" width=\"631\" height=\"636\" class=\"alignnone size-medium wp-image-148302\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_venv-e1697496487822-631x636.png 631w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_venv-e1697496487822-150x150.png 150w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_venv-e1697496487822-768x774.png 768w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_venv-e1697496487822-100x100.png 100w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_venv-e1697496487822.png 855w\" sizes=\"(max-width: 631px) 100vw, 631px\" \/><\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n<script type=\"text\/javascript\">\r\ndocument.getElementById('virtualenv').style.display = 'none';\r\n<\/script><\/p><\/div>\n<div id=\"conda\">\n&nbsp;<\/p>\n<ol type=\"A\">\n<li>You will need to install <code><span class=\"command\">notebook<\/span><\/code> in your conda env for the kernel to be available in the OnDemand App. This is done with the following:\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">conda activate<\/span> <span class=\"placeholder\">my_conda_env<\/span>\r\n<span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span> <span class=\"command\">pip install notebook<\/span><\/code><\/pre>\n<\/li>\n<p>&nbsp;<\/p>\n<li>On the Jupyter Notebook request page, specify your version of miniconda in the <b>List of Modules to load<\/b> field AND add the command to activate your environment under the <b>Pre-Launch Commands (optional)<\/b> field. Then click <b>Launch<\/b> to submit the request.<br \/>\nUnchanged: <img loading=\"lazy\" src=\"\/tech\/files\/2023\/10\/jupyter_conda-e1697496462903.png\" alt=\"\" width=\"629\" height=\"624\" class=\"alignnone size-full wp-image-148303\" srcset=\"https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_conda-e1697496462903.png 629w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_conda-e1697496462903-150x150.png 150w, https:\/\/www.bu.edu\/tech\/files\/2023\/10\/jupyter_conda-e1697496462903-100x100.png 100w\" sizes=\"(max-width: 629px) 100vw, 629px\" \/><\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n<script type=\"text\/javascript\">\r\ndocument.getElementById('conda').style.display = 'none';\r\n<\/script><\/p><\/div>\n<\/ol>\n<p><script type=\"text\/javascript\">\r\nfunction show_manager(manager){    \r\nif (manager == \"python\"){\r\n \t   document.getElementById('python').style.display = 'block';\r\n \t   document.getElementById('virtualenv').style.display = 'none';\r\n \t   document.getElementById('conda').style.display = 'none';\r\n           document.getElementById('backtotop').style.display = 'block';\r\n  \t} \r\nelse if (manager == \"virtualenv\"){\r\n \t   document.getElementById('python').style.display = 'none';\r\n \t   document.getElementById('virtualenv').style.display = 'block';\r\n \t   document.getElementById('conda').style.display = 'none';\r\n           document.getElementById('backtotop').style.display = 'block';\r\n  \t} \r\nelse if (manager == \"conda\"){\r\n \t   document.getElementById('python').style.display = 'none';\r\n \t   document.getElementById('virtualenv').style.display = 'none';\r\n \t   document.getElementById('conda').style.display = 'block';\r\n           document.getElementById('backtotop').style.display = 'block';\r\n         }    \r\nelse {\r\n \t   document.getElementById('python').style.display = 'none';\r\n \t   document.getElementById('virtualenv').style.display = 'none';\r\n \t   document.getElementById('conda').style.display = 'none';\r\n           document.getElementById('backtotop').style.display = 'block';\r\n     }\r\n }\r\n<\/script><br \/>\n&nbsp;<\/p>\n<p><a name=\"desktop\"><\/a><\/p>\n<h2>Jupyter OnDemand Desktop<\/h2>\n<p>Use Jupyter within an Interactive Desktop session for long-running notebooks where you want to close your browser. When launched as an Interactive App as described above, it will stop running if your browser is closed.<\/p>\n<ol type=\"1\">\n<li>Click one of the Python environment options below for further instructions within that package manager:<br \/>\n<table border=\"0\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><input name=\"desktop_manager\" id=\"desktop_python1\" onclick=\"show_desktop_manager('desktop_python')\" value=\"desktop_python\" type=\"radio\" \/><br \/>\n<strong><label for=\"desktop_python1\">Python<\/label><\/strong><\/td>\n<td style=\"text-align: center;\"><input name=\"desktop_manager\" id=\"desktop_virtualenv1\" onclick=\"show_desktop_manager('desktop_virtualenv')\" value=\"desktop_virtualenv\" type=\"radio\" \/><br \/>\n<strong><label for=\"desktop_virtualenv1\">Python: virtualenv<\/label><\/strong><\/td>\n<td style=\"text-align: center;\"><input name=\"desktop_manager\" id=\"desktop_conda1\" onclick=\"show_desktop_manager('desktop_conda')\" value=\"desktop_conda\" type=\"radio\" \/><br \/>\n<strong><label for=\"desktop_conda1\">Miniconda: conda env<\/label><\/strong><\/td>\n<td style=\"text-align: center;\"><input name=\"desktop_manager\" id=\"desktop_select1\" onclick=\"show_desktop_manager('desktop_select')\" value=\"desktop_select\" type=\"radio\" \/><br \/>\n<strong><label for=\"desktop_select1\">hide<\/label><\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<div id=\"desktop_python\">\n&nbsp;<\/p>\n<ol type=\"A\">\n<li>Load python module:\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">module load python3\/3.10.12<\/span><\/code><\/pre>\n<\/li>\n<p>&nbsp;<\/p>\n<li>Launch Jupyter from the command line:\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">jupyter notebook<\/span><\/code><\/pre>\n<\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n<script type=\"text\/javascript\">\r\ndocument.getElementById('desktop_python').style.display = 'none';\r\n<\/script><\/p><\/div>\n<div id=\"desktop_virtualenv\">\n&nbsp;<\/p>\n<ol type=\"A\">\n<li>You will need to install <code><span class=\"command\">notebook<\/span><\/code> in your virtualenv for the kernel to be available Jupyter. This is done with the following:\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">source<\/span> <span class=\"placeholder\">\/path\/to\/my_venv\/bin\/activate<\/span>\r\n<span class=\"prompt\">(my_venv) [rcs@scc1 ~]<\/span> <span class=\"command\">pip install notebook<\/span><\/code><\/pre>\n<\/li>\n<p>&nbsp;<\/p>\n<li>Launch Jupyter from the command line within your virtualenv:\n<pre><code class=\"code-block\"><span class=\"prompt\">(my_venv) [rcs@scc1 ~]<\/span> <span class=\"command\">jupyter notebook<\/span><\/code><\/pre>\n<\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n<script type=\"text\/javascript\">\r\ndocument.getElementById('desktop_virtualenv').style.display = 'none';\r\n<\/script><\/p><\/div>\n<div id=\"desktop_conda\">\n&nbsp;<\/p>\n<ol type=\"A\">\n<li>You will need to install <code><span class=\"command\">notebook<\/span><\/code> in your conda environment for the kernel to be available in Jupyter. This is done with the following:\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">conda activate my_conda_env<\/span>\r\n<span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span> <span class=\"command\">pip install notebook<\/span><\/code><\/pre>\n<\/li>\n<p>&nbsp;<\/p>\n<li>Launch Jupyter from the command line within your conda environment:\n<pre><code class=\"code-block\"><span class=\"prompt\">(my_conda_env) [rcs@scc1 ~]<\/span> <span class=\"command\">jupyter notebook<\/span><\/code><\/pre>\n<\/li>\n<\/ol>\n<p>&nbsp;<br \/>\n<script type=\"text\/javascript\">\r\ndocument.getElementById('desktop_conda').style.display = 'none';\r\n<\/script><\/p><\/div>\n<\/ol>\n<p><script type=\"text\/javascript\">\r\nfunction show_desktop_manager(desktop_manager){    \r\nif (desktop_manager == \"desktop_python\"){\r\n \t   document.getElementById('desktop_python').style.display = 'block';\r\n \t   document.getElementById('desktop_virtualenv').style.display = 'none';\r\n \t   document.getElementById('desktop_conda').style.display = 'none';\r\n           document.getElementById('desktop_backtotop').style.display = 'block';\r\n  \t} \r\nelse if (desktop_manager == \"desktop_virtualenv\"){\r\n \t   document.getElementById('desktop_python').style.display = 'none';\r\n \t   document.getElementById('desktop_virtualenv').style.display = 'block';\r\n \t   document.getElementById('desktop_conda').style.display = 'none';\r\n           document.getElementById('desktop_backtotop').style.display = 'block';\r\n  \t} \r\nelse if (desktop_manager == \"desktop_conda\"){\r\n \t   document.getElementById('desktop_python').style.display = 'none';\r\n \t   document.getElementById('desktop_virtualenv').style.display = 'none';\r\n \t   document.getElementById('desktop_conda').style.display = 'block';\r\n           document.getElementById('desktop_backtotop').style.display = 'block';\r\n         }    \r\nelse {\r\n \t   document.getElementById('desktop_python').style.display = 'none';\r\n \t   document.getElementById('desktop_virtualenv').style.display = 'none';\r\n \t   document.getElementById('desktop_conda').style.display = 'none';\r\n           document.getElementById('desktop_backtotop').style.display = 'block';\r\n     }\r\n }\r\n<\/script><\/p>\n<p>&nbsp;<\/p>\n<p><a name=\"batch\"><\/a><\/p>\n<h2>Jupyter Batch Jobs<\/h2>\n<p>To run a Jupyter Notebook as a batch job there are two options:<\/p>\n<ul>\n<li><strong>Option 1: Convert Notebook to Python Script<\/strong><br \/>\nConvert notebook to a <code><span class=\"command\">.py<\/span><\/code> file that can be run as a batch job. This can be done within a batch job or beforehand.<\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">jupyter nbconvert --to script<\/span> <span class=\"placeholder\">NOTEBOOK_NAME.ipynb<\/span>\r\n<span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">python<\/span> <span class=\"placeholder\">NOTEBOOK_NAME.py<\/span><\/code><\/pre>\n<\/li>\n<li><strong>Option 2: Execute as Notebook File<\/strong><br \/>\nIt&#8217;s also possible to execute the notebook directly from the <code><span class=\"command\">.ipynb<\/span><\/code> file. Results are saved within the notebook exactly the way they would be if run from within Jupyter. <\/p>\n<pre><code class=\"code-block\"><span class=\"prompt\">[rcs@scc1 ~]<\/span> <span class=\"command\">jupyter nbconvert --to notebook --execute <\/span> <span class=\"placeholder\">NOTEBOOK_NAME.ipynb<\/span><\/code><\/pre>\n<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\n<a href=\"#top\">Back to top<\/a><\/p>\n<div style=\"float: right;\">\n<p id=\"last-modified-timestamp\" style=\"margin: 0;\">Last updated: Loading&#8230;<\/p>\n<\/div>\n<p><script>\r\ndocument.addEventListener('DOMContentLoaded', function() {\r\n    \/\/ Get the content of the meta tag\r\n    var lastUpdatedContent = document.querySelector('meta[name=\"last-updated\"]').content;\r\n    \r\n    \/\/ Parse the content into a Date object\r\n    var lastUpdatedDate = new Date(lastUpdatedContent);\r\n    \r\n    \/\/ Format the date\r\n    var formattedDate = lastUpdatedDate.toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' });\r\n    \r\n    \/\/ Update the HTML element with the formatted date\r\n    document.getElementById('last-modified-timestamp').innerHTML = 'Last updated: ' + formattedDate;\r\n});\r\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Jupyter can be deployed on the SCC in a number of ways. We recommend use of the Jupyter OnDemand Interactive App in combination with your preferred python environment (i.e. Python or Conda). &nbsp; &nbsp; Sections Jupyter OnDemand Interactive App Jupyter OnDemand Desktop Jupyter Batch Jobs &nbsp; Jupyter OnDemand Interactive App This is our recommended way&#8230;<\/p>\n","protected":false},"author":1692,"featured_media":0,"parent":147624,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148244"}],"collection":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/users\/1692"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/comments?post=148244"}],"version-history":[{"count":50,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148244\/revisions"}],"predecessor-version":[{"id":151809,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/148244\/revisions\/151809"}],"up":[{"embeddable":true,"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/pages\/147624"}],"wp:attachment":[{"href":"https:\/\/www.bu.edu\/tech\/wp-json\/wp\/v2\/media?parent=148244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}