ImportError: No module named 'xlrd'

I am currently using PyCharm with Python version 3.4.3 for this particular project.

This PyCharm previously had Python2.7, and I upgraded to 3.4.3.

I am trying to fetch data from an Excel file using Pandas.

Here is my code:

import pandas as pd

df = pd.read_excel("File.xls", "Sheet1")
print (df)

When I ran this code, I am getting this error.

ImportError: No module named 'xlrd'

I searched Stackoverflow and found some suggestions: I tried with

pip install xlrd

But, when I did that, the message says

"Requirement already satisfied: xlrd in ./anaconda2/usr/lib/python2.7/site-packages"

Any suggestion?


Solution 1:

I had the same problem. I went to the terminal (Using Linux), and typed

sudo pip3 install xlrd

Then I imported xlrd in python and used the same code:

df = pd.read_excel("File.xlsx", "Sheet1")
print (df)

It worked for me!!

Solution 2:

You have to download xlrd library because pandas require it.

In Pycharm I downloaded it in File -> Settings -> Project: [PROJECT NAME] -> Project Interpreter enter image description here

Solution 3:

Running the pip install xlrd completed the installation, but that did not resolve the "no named module named xlrd" error.

Copying the xlrd folder to the same folder where the .py programs are stored, resolved this issue.