0
votes

I am new to Google cloud and datalab. I struggled to get it up and running. I was wondering how I could just import user-written .py files within datalab notebook.

I tried using "pip install git+~~". It installs, but it seems like it is installing in the wrong directory or something. I was not able to import it.

Please help me out.

Btw, I wonder how I could "pip install git+~~" for private repo. Notebook isn't interactive. I tried echo userid | echo password | pip install git+~

Thank you!

1
Not sure if this helps you at all: stackoverflow.com/questions/33174293/… - kayleeFrye_onDeck
@kayleeFrye_onDeck Thank you for the reply. I have already checked them out. That's how I tried the thing I mentioned. I am asking more details on the second posts, how I would import it once installed. Thanks! - Bosuk Hong

1 Answers

1
votes

Assuming the python package is created correctly, the import should work after installing the python package.

To install a package from Github (using the xrld package as an example), run either

!pip install https://github.com/python-excel/xlrd/archive/master.zip
import xlrd

or

!pip install git+http://github.com/python-excel/xlrd.git
import xlrd

I ran through the process of creating a minimal python package and was able to import it successfully in Google Cloud Datalab with:

import funniest
print funniest.joke()

After installing it with:

!cd funniest && pip install .

You can check the install location by running the following code:

>> funniest.__file__
'/usr/local/lib/python2.7/dist-packages/funniest/__init__.pyc'

Could you try also try creating a minimal python package and see if that works? You may be able to spot a subtle the difference between your package and the minimal package.