Libraries and Modules in Python

Setup

This lesson will require a few extra steps to setup some of the modules we require. As usual start by cloning the azure library.

Setup:

Log on to notebooks.azure.com and clone the lesson library.

Now we must locally install the modules that are included in this lesson, we do this using pip:

In [1]:
!pip install ./code/superheros
Processing /home/travis/build/arc-lessons/libraries-modules/code/superheros
Building wheels for collected packages: superheros
  Building wheel for superheros (setup.py) ... - done
  Stored in directory: /tmp/pip-ephem-wheel-cache-4tj12ijy/wheels/93/1c/58/307c11b37daa5ca7fb8c87ed43a397c24fec99ec9a83f41f51
Successfully built superheros
Installing collected packages: superheros
Successfully installed superheros-1.0

pip ...what!?

The above command looks a bit cryptic, so let's take a quick look at it. pip is the Python package manager, it installs and manages all of the Python specific modules. You can even install full applications that are written in Python using pip.

The install command for pip will perform the installation procedure for the package that follows. If the package is well written and has been set up correctly, it will also resolve all its dependencies automatically.

Following install, rather than a package name, we have ./code/superheros. This tells pip that we don't want to look in PyPI (The Python Package Index), but we want to install modules we have locally. Specifically it requires the path to a setup.py file, which in our case is located in the parent directory ./code/superheros. The setup.py file contains the information pip needs to install files for this lesson.

Once the package has been installed, it may be necessary to restart the kernel for the Jupyter notebook. This can be done by clicking the button on the toolbar.

To check this has worked we can try importing the test module as follows:

In [2]:
import check_superheros
Package for the libraries-modules lesson installed correctly

If your output looks the same as above, you are ready to continue with the lesson.