Search code examples
google-cloud-platformjupytergoogle-cloud-datalab

How to import xlrd into Google Cloud Datalab


I am trying to import some data from an Excel spreadsheet into Jupyter on Google Cloud Datalab:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import xlrd
import re
plt.style.use('ggplot')

I get the following error:

ImportError                               Traceback (most recent call last)
<ipython-input-1-9a99b78364cd> in <module>()
      2 import numpy as np
      3 import matplotlib.pyplot as plt
----> 4 import xlrd
      5 import re
      6 plt.style.use('ggplot')

ImportError: No module named xlrd

I understand that I have to install the xlrd module. How can I get this done or request for this to be done on Datalab?

thanks in advance!


Solution

  • Run either of the following in a cell within a datalab notebook:

    !pip install xlrd
    

    or

    %%bash
    pip install xlrd