5

I'm using google datalab on google cloud platform. Worked great on the first try and I love how easy it is to now run a jupyter notebook server in the cloud (faster than starting up a localhost server). It's fantastic.

But now I want to install python libraries not included in the basic datalab environment (specifically I need the Bokeh plotting library).

So I opened a google cloud shell from the google cloud console where I manage this jupyter notebook instance, installed miniconda and then the bokeh library. Everything ran without error (e.g. bokeh installs several dependencies along the way), but my jupyter notebook on datalab (which can import other libraries like numpy) still gives me a "no module named bokeh.plotting" error.

Any ideas? Thanks in advance.

JHuw
  • 250
  • 2
  • 12
  • Were you able to install via `conda`, or only `pip` per the below answer? I'm looking for a `conda` solution: https://stackoverflow.com/questions/47025059/install-conda-package-from-google-datalab – Max Ghenis Oct 30 '17 at 22:29

1 Answers1

5

You can do this inside a notebook:

%%bash
pip install bokeh
Max Ghenis
  • 14,783
  • 16
  • 84
  • 132
Graham Wheeler
  • 2,734
  • 1
  • 19
  • 23
  • Or more generally, for multi-line commands %%bash # whatever command – Dinesh Oct 16 '15 at 22:30
  • Thanks that worked. Note that as @Dinesh points out it is %%bash and the pip install command on a newline. As first answered it was rendered as a oneliner with %bash rather than %%bash – JHuw Oct 17 '15 at 04:30
  • Yes, thanks, updated. I had a separate line but SO folded them. – Graham Wheeler Oct 17 '15 at 17:56
  • So, just so that I can understand.. Is there a simple answer to why the conda installation from the cloud shell did not make the library available? Are they different python environments, or something? – JHuw Oct 17 '15 at 18:26
  • Datalab is running in a container in the VM so it is sandboxed from the rest of the VM. – Graham Wheeler Oct 17 '15 at 18:29
  • Last question. This %%bash magic runs non-Interactive shell commands. Is there a way to get an interactive shell for those times one needs interaction (e.g. conda installer that prompts y/n to continue)? – JHuw Oct 17 '15 at 19:13
  • 1
    No interactive shell although you can use pipe, so maybe "echo 'y' | ..." will work – Graham Wheeler Oct 21 '15 at 22:14