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?
xlrd is a library for reading data and formatting information from Excel files in the historical . xls format.
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!!
You have to download xlrd library because pandas require it.
In Pycharm I downloaded it in File -> Settings -> Project: [PROJECT NAME] -> Project Interpreter
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.
The problem seems to be because of multiple python versions in the system, where requirement might be satisfied for one and not for the other.
In this case the requirement is satisfied for python2 but not for python3, you need to specify that the download needs to be for python3.
In reference to the answers mentioned above, what worked for me is
python3 -m pip install xlrd
specifying python3 rather than pip3 worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With