This notebook will help you install the SAS NBExtensions

The process includes a mix of command line and python code and can be done either systemwide or for the current user depending on the permission level the user has.

This code will import the notebook module and display the paths that Juypter will search for NBExtensions


In [ ]:
import notebook
from __future__ import print_function
from jupyter_core.paths import jupyter_data_dir, jupyter_path
print(jupyter_data_dir())
print(jupyter_path())

To Install Systemwide

This will require you to be root or have sudo rights

The ! below is a "magic" that runs os commands. The command below assumes your cuurent working directory is inside the sas_kernel cloned repository. If that is not the case then you can either:

  1. change the path below
  2. use the ! to change the current working directory

If this command is successful you should see a note about files being copied from the sas_kernel location to /usr/local/share/jupyter/nbextensions/


In [ ]:
! sudo jupyter nbextension install sas_kernel/sas_kernel/nbextensions/showSASLog

This python code will check on the nbextension in systemwide folders (user=False is the flag for this) and then enable the extension. If anything goes wrong, you'll see the Extension not found message


In [ ]:
if notebook.nbextensions.check_nbextension('showSASLog', user=False):
    E = notebook.nbextensions.EnableNBExtensionApp()
    E.enable_nbextension('showSASLog/main')
else:
    print ("Extension not found")

In [ ]:
! sudo jupyter nbextension install /root/sas_kernel/sas_kernel/nbextensions/theme

In [ ]:
if notebook.nbextensions.check_nbextension('theme', user=False):
    E = notebook.nbextensions.EnableNBExtensionApp()
    E.enable_nbextension('theme/theme_selector')
else:
    print ("Extension not found")

To install for the Current User

The ! below is a "magic" that runs os commands. The command below assumes your cuurent working directory is inside the sas_kernel cloned repository. If that is not the case then you can either:

  1. change the path below
  2. use the ! to change the current working directory

If this command is successful you should see a note about files being copied from the sas_kernel location to /usr/local/share/jupyter/nbextensions/


In [ ]:
! jupyter nbextension install sas_kernel/sas_kernel/nbextensions/showSASLog --user

This python code will check on the nbextension in user folders ~/ (user=True is the flag for this) and then enable the extension. If anything goes wrong, you'll see the Extension not found message


In [ ]:
if notebook.nbextensions.check_nbextension('showSASLog', user=True):
    E = notebook.nbextensions.EnableNBExtensionApp()
    E.enable_nbextension('showSASLog/main')
else:
    print ("Extension not found")

In [ ]:
! jupyter nbextension install /root/sas_kernel/sas_kernel/nbextensions/theme --user

In [ ]:
if notebook.nbextensions.check_nbextension('theme', user=True):
    E = notebook.nbextensions.EnableNBExtensionApp()
    E.enable_nbextension('theme/theme_selector')
else:
    print ("Extension not found")

Check to see what NBExtensions are Installed

This code will produce a simple table listing the installed extensions this user has access to. It will be a mix of user and systemwide extensions if applicable.

Is should list at least the following:

Extension name
showSASLog/main
theme/theme_selector

In [ ]:
from notebook.services.config import ConfigManager
from IPython.display import HTML
ip = get_ipython()
cm = ConfigManager(parent=ip, profile_dir=ip.profile_dir.location)
extensions =cm.get('notebook')
table = ""
for ext in extensions['load_extensions']:
    table += "<tr><td>%s</td>\n" % (ext)

top = """
<table border="1">
  <tr>
    <th>Extension name</th>
  </tr>
"""
bottom = """
</table>
"""
HTML(top + table + bottom)