2

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?

1 Answers1

1

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.

sys.path.append('/mnt/scratch/p2packages/')

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

https://lab.beakernotebook.com/approval/view/3c73a144-3ec1-11e6-935b-8ff81ae480a3

Community
  • 1
  • 1
melmac
  • 51
  • 3