Jupyterhub Offline install (without internet!)

Installing Jupyterhub in an offline environment (without internet)



What? 
Installing Jupyterhub catering to multiple users offline (without internet connectivity)
Why?
In scenarios where the Enterprise environment or the Corporate Lab Servers are not connected to the internet, offline installations are the only way to install a software. Sometimes many number of days (Sometimes weeks) are spent to have a successful installation. This is written to save some man days for offline Jupyterhub installations
Environment
Cent OS 7, Anaconda 5.1, Jupyterhub 0.8.1


For one of the projects that I am working with, we had to setup Jupyterhub in a lab environment that did not have internet connectivity. Though,  a lot of information is available for online installations, I couldn't find a link that provided the first set of complete basic steps for an offline installation .... like a "hello world" for Jupyterhub offline installs and hence this blog! Let us go to the How part now...

By the time you read this blog, a lot of things might have changed....for example - the packages needed to install the jupyterhub version that you want. But, if the steps are followed you should most probably succeed installing a working version.

What do you need:


  • Linux box that has internet connectivity - let us call this local box
  • Linux box that does not have no internet connectivity - let us call this dev box
  • Connectivity from your local box to dev box to transfer files... if you cannot do this, then pls do discuss with your admin team on the way to get the files in dev box
  • Relevant privileges to install the software packages.. I had admin privileges in the dev box

Download the file bzip2-1.0.6-13.el7.x86_64.rpm to local box

$wget https://centos.pkgs.org/7/centos-x86_64/bzip2-1.0.6-13.el7.x86_64.rpm.html
If your dev box has bzip utility, then downloading the bzip rpm can be skipped. This rpm is for Cent OS x86_64 architecture. Pls. find the appropriate package for your Linux box.
https://centos.pkgs.org/7/centos-x86_64/ was used for my case



Transfer the file bzip2-1.0.6-13.el7.x86_64.rpm (if it does not come with the standard build process in the dev box) – from local box to dev box.  

Assumption: You have connectivity from your local box to dev box. If you do not have the connectivity, then you need to discuss with your admin team on the way to get the software to the dev box. 



      Download Anaconda3-5.1.0-Linux-x86_64.sh to local box
      $wget https://repo.anaconda.com/archive/Anaconda3-5.1.0-Linux-x86_64.sh 



     Go to Anaconda.com and search for the latest Linux version...At the time of this writing, https://www.anaconda.com/download/#linux provides the link for downloading the latest version 5.1.



 $sudo rpm -Uvh bzip2-1.0.6-13.el7.x86_64.rpm 
 This would install the RPM bzip2 in dev box




Run the following command in both local and dev box folder 

$bash ./Anaconda3-5.1.0-Linux-x86_64.sh


Accept the terms and conditions.

Specify the folder in which Anaconda needs to be installed, if you do not want to go with the default location

Also, finally pls. state yes to the fact that bashrc/path will be updated. This makes it easier for the env to point to right Python version.



Instructions for Anaconda installation in Linux is present in the following page


You can skip step 8, if you do not want Microsoft's VS for Python. At the time of writing this
blog, step 8 deals with installing Microsoft VS code. 


Test the fact that Python has been installed. If you had an existing python installation in your machine, you should see the latest version being referred (the system defaults to latest Python - if the env variables had not been altered)

$source ~/.bashrc
$python
This will start the Python shell and shows the Python version. Check the version - it
should show the version that was bundled with your Anaconda version. If not, make sure that the system defaults to latest Python.

Type exit() in python shell to exit.


Find all the packages that are needed for jupyterhub (in the local box)
$conda install -c conda-forge  jupyterhub

The beauty of conda is that it provides all the needed packages - even non Python. That was why I used conda instead of pip!

This will first show all the packages that will be downloaded. At the time of this writing, the following packages were shown:

    package                                            |            build
    ----------------------------------------------|-------------------------------------------------
    urllib3-1.22                                       |       py36_0         154 KB  conda-forge
    requests-2.18.4                                 |       py36_1          91 KB  conda-forge
    libgcc-ng-7.2.0                                  |       hdf63c60_3         6.1 MB
    idna-2.6                                            |       py36_1         122 KB  conda-forge
    sqlalchemy-1.2.6                               |       py36_0         1.6 MB  conda-forge
    certifi-2018.1.18                               |       py36_0         143 KB  conda-forge
    sqlite-3.20.1                                     |                2         1.3 MB  conda-forge
    wheel-0.31.0                                    |           py36_0          62 KB  conda-forge
    zlib-1.2.11                                       |                0          93 KB  conda-forge
    ncurses-5.9                                      |               10         1.1 MB  conda-forge
    six-1.11.0                                        |           py36_1          21 KB  conda-forge
    cffi-1.11.5                                       |           py36_0         406 KB  conda-forge
    pysocks-1.6.8                                  |           py36_1          22 KB  conda-forge
    setuptools-39.0.1                            |           py36_0         552 KB  conda-forge
    alembic-0.9.9                                 |             py_0         104 KB  conda-forge
    asn1crypto-0.24.0                           |           py36_0         154 KB  conda-forge
    mako-1.0.7                                     |           py36_0         115 KB  conda-forge
    jinja2-2.10                                     |           py36_0         183 KB  conda-forge
    tornado-5.0.2                                |           py36_0         657 KB  conda-forge
    nodejs-6.13.1                                |                0        11.9 MB  conda-forge
    ipython_genutils-0.2.0                  |           py36_0          36 KB  conda-forge
    jupyterhub-0.8.1                          |           py36_0         1.6 MB  conda-forge
    python-editor-1.0.3                      |           py36_0           9 KB  conda-forge
    markupsafe-1.0                            |           py36_0          32 KB  conda-forge
    xz-5.2.3                                       |                0         854 KB  conda-forge
    openssl-1.0.2o                             |                0         3.5 MB  conda-forge
    configurable-http-proxy-3.1.0      |                0         249 KB  conda-forge
    readline-7.0                                |                0         838 KB  conda-forge
    decorator-4.3.0                           |             py_0          10 KB  conda-forge
    tk-8.6.7                                       |                0         3.1 MB  conda-forge
    python-3.6.5                               |                1        21.0 MB  conda-forge
    pamela-0.3.0                              |           py36_0          11 KB  conda-forge
    ca-certificates-2018.1.18            |                0         140 KB  conda-forge
    chardet-3.0.4                            |           py36_0         189 KB  conda-forge
    pip-9.0.3                                  |           py36_0         1.7 MB  conda-forge
    traitlets-4.3.2                          |           py36_0         131 KB  conda-forge
    pycparser-2.18                         |           py36_0         168 KB  conda-forge
    pyopenssl-17.5.0                      |           py36_1          81 KB  conda-forge
    libstdcxx-ng-7.2.0                    |       hdf63c60_3         2.5 MB
    cryptography-2.2.1                  |           py36_0         846 KB  conda-forge
    libgcc-7.2.0                            |       h69d50b8_2         304 KB
    libffi-3.2.1                              |                3          47 KB  conda-forge
    python-oauth2-1.0.1               |           py36_0          86 KB  conda-forge
    python-dateutil-2.7.2              |             py_0         203 KB  conda-forge

Post this list , you will be also shown a list of packages that will get installed… 

After that you will be prompted to enter yes/no.

If you press “yes” all the packages will be downloaded and installed. The environment location (Directory) where conda is going to work with for this command will be shown before the list of downloads. 
If you do not want to press “yes” for some reason, then you should individually search and download all the packages. Luckily most of the packages are in conda-forge. 


Channel Creation in dev box

I chose the /opt directory to create a folder called channel/linux-64. Directory  linux-64  will contain all the required packages to install jupyterhub

$cd /opt
$mkdir channel
$cd channel
$mkdir linux-64
$ cd /opt

All the packages downloaded by conda (or by yourself) in the local box needs to be moved to the linux-64 directory in dev box. 

Run the below command to index the channel in dev box
$channel index /opt/channel/linux-64
Create a Conda environment from the existing root environment in dev box
$conda create --name jupyter_dev_install --clone base

The environment that is getting created is called jupyter_dev_install
There are ways to create a conda environment offline. This is one way by which we can create wherein Conda does not refer to repos in the internet.

Activate the jupyter_dev_install environment by using below command in dev box
$source activate jupyter_dev_install
Now, comes the Jupyterhub installation in dev box
$conda install -c /opt/channel/linux-64 jupyterhub --override-channels

Enter y for installing jupyterhub. Finally, Jupyterhub gets installed!



Comments

Popular posts from this blog

Jupyterhub configurations - https (with a self signed certificate) and starting with a shared directory for multiple users