ImportError: No module named 'xlrd'
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
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.
Solution 4
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.
Solution 5
For me the solution was uninstalling xlrd
using pip uninstall xlrd
, and then installing it again using pip install xlrd
.
Related videos on Youtube
![Java](https://i.stack.imgur.com/51bIs.jpg?s=256&g=1)
Java
Updated on January 20, 2022Comments
-
Java over 2 years
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?
-
jonrsharpe almost 7 years
pip3 install xlrd
? PyCharm will already be offering to install it through the context sensitive help if you've selected the correct interpreter for the project. -
Joe almost 7 yearsI agree with jon you are probably pointing at the wrong interpreter when running pip. If you go to you pycharm settings - project interpreter you will see exactly where pycharm is executing.
-
Mr_U4913 almost 7 yearsopen your anaconda prompt : conda install xlrd
-
jacoblaw almost 7 yearswhat pip outputs clearly states you have it for python 2.7, and are trying to install for 2.7, but you are using 3.4.3 in pycharm.
-
Java almost 7 yearsI tried all above (pip3 install xlrd -> it says "The program 'pip3' is currently not installed. You can install it by typing: sudo apt-get install python3-pip, so I did. I went thru the process, and message said "python3-pip is already the newest version." I checked the interpreter, and it is pointing to 3.4.3 in PyCharm. I typed conda install xlrd. It went thru the process. It says "All requested packages already installed. But it says xlrd 1.0.0 py27_0.
-
voidpro almost 7 yearsOne way is, copy the packege
xlrd
from./anaconda2/usr/lib/python2.7/site-packages
to thelib
directory PyCharm installation directory. This is becausepip
installs the packeges toanaconda2
by default. -
Mohamed A M-Hassan about 6 yearsthanks @KingJava I have same problem and I used "pip install xlrd" and it worked with me
-
WhitneyChia about 4 yearsShouldn't this be a transitive dependency for pandas and install when pandas is installed? I hit the same problem but this should've downloaded on its own right?
-
-
David Culbreth over 5 yearsI would caution that this method may not necessarily work for newer versions of Python, as 2.7 is not completely compatible with 3.x
-
Steven C. Howell over 5 yearsYou are correct that you need to install xlrd. Rather than moving/copying the folder, try importing xlrd (
import xlrd
) before reading your Excel file. -
Amal Raj over 5 yearsYes...I did inport xlrd before trying to open the Excel file. But i kept getting the error...till i copied the folder
-
Adam Wheeler over 4 years
-
D.L almost 4 yearsI ran into the same issue (windows10). tried pip install, pip3 install and conda install. All failed. Moved the XLRD folder ('pip show XLRD') to the .py files folder and it works. Its not a great solution, but the only thing that worked.