0

I am trying to read an excel file in Python. When I try and import the correct module, it doesn't work.

My code is:

from xlrd import open_workbook
wb = openpyxl.load_workbook('example.xlsx')
type(wb)

and I get this error:

from xlrd import open_workbook
ModuleNotFoundError: No module named 'xlrd'

Can anyone help me please?

JJJ
  • 31,545
  • 20
  • 84
  • 99

2 Answers2

0

It looks like xlrd is not found/does not exist for the instance of Python you're using.

Assuming you're using Python3, you'll want to use pip3 to get modules that aren't already available. Install Python 3's pip with

sudo aptget install python3-pip Then install packages with pip3 install xlrd

If you're using Python2, follow the directions from Adam and do pip install xlrd

sudo_coffee
  • 740
  • 1
  • 9
  • 26
0

Try typing into the cmd prompt or terminal:

python -c "import xlrd; print xlrd.__VERSION__"

If that fails try using pip to install it.

pip install xlrd

you can try the first step again to check that it's worked

Adam Slack
  • 444
  • 6
  • 11