Dasha Merkusheva Dasha Merkusheva - 1 year ago 97
Python Question

Adding non standard Python library to Beaker Lab notebook

I would like to use fiona (and a few other third party libraries from Github) in my Beaker Lab notebook and it's not included in the default installation.

Is there a way to install new Python packages?

Answer Source

To use python packages in a Python 2 Notebook you should first use the My Cloud Resources to create a directory ‘p2packages’ in your scratch space.

Then you can append the path to your sys.path variable. This should be done in every notebook that requires your custom packages.


Next step is to use the embedded pip to install the required package and its dependencies.

Usually it is enough to specify a –target option, but in other cases you might want to check Installing python module within code for other options that might be required by other packages.

import pip
pip.main(['install', '--target=/mnt/scratch/p2packages/', 'pattern' ])

Now you can use this new package in your notebook

Example in Beaker Lab: https://lab.beakernotebook.com/publications/2ff702e6-3ebf-11e6-b0e2-5f05deb51e12?fullscreen=true

Here's an example for python 3


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download