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 extract 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 get this error.

 ImportError: No module named 'xlrd' 

I searched Stackoverflow and found some suggestions: I tried using

 pip install xlrd 

But when I did, the message says

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

Any suggestion?

+33
python pandas ubuntu pycharm
source share
10 answers

I have the same problem. I went to the terminal (using Linux) and typed

 sudo pip3 install xlrd 

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

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

It worked for me !!

+37
source share

You must download the xlrd library because pandas require it.

In Pycharm, I downloaded it to File → Settings → Project: [PROJECT NAME] → Project Interpreter enter image description here

+5
source share

Running pip install xlrd completed the installation, but this did not help to resolve the "without xlrd module name" error.

Copying the xlrd folder to the same folder where the .py programs are stored solved this problem.

+4
source share

Click on the Bulb icon next to "import xlrd" and click on the clrd installation package, it will automatically install the package

+3
source share

The problem seems to be related to several versions of Python on a system where requirements can be met for one, and not for the other.

In this case, the requirement is satisfied for python2, but not for python3, you must specify what the download should be for python3.

Regarding the answers mentioned above, what worked for me,

 python3 -m pip install xlrd 

specifying python3 and not pip3, I succeeded.

+2
source share

If you are in a terminal under Bash or any other semi-professional shell with tab completion, try writing pip and then <tab> . If I do this, I see:

 none@vacuum:~$ pip pip pip3 pip3.5 pip3.6 

As you can see, I can choose to run pip commands only under pip , but I can choose even newer versions of pip. To find out which version is associated with the pip command (with nothing else), run pip as usual with the --version or -V flag. In my case pip -V gives:

 none@vacuum:~$ pip -V pip 9.0.1 from /usr/local/lib/python3.6/dist-packages (python 3.6) 

In addition, if you are developing in PyCharm, you can press Alt+Enter when the cursor is under the name of a module that cannot be imported to open a context-sensitive floating menu that allows you to install the module. (You can also manage the list of installed modules for a specific version of Python in the PyCharm settings menu in the Project Interpreter submenu.)

0
source share

I have Python 2.7, 3.5, and 3.6 in my Linux Mint machine for some reason.

My spy uses Python 3.5, and I had the same problem. What i did is

  • go to the /usr/local/lib/python2.7/dist-packages folder
  • Copy the xlrd folder (note that for this you need to right-click and open as root)
  • Now go to /usr/local/lib/python3.5/dist-packages or /usr/local/lib/python3.6/dist-packages and insert the xlrd folder.

It worked for me !!!

This method does not change the default path, so I can continue to work with Python 2.7 without any harm (something like SageMath which I widely use)

0
source share

The same thing happened to me using pycharm, I installed it with pip, pip3 and anaconda and it still didn't work. I manually installed the package from pycharm-> preferences → project → project interpreter → + and it worked.

0
source share

Solved this problem as @Binamrata Sharma commented

Install xlrd: sudo pip3 install xlrd

Successful completion after deployment

enter image description here

0
source share

If you are using a virtual environment, use "pipenv install xlrd" instead of "pip install xlrd". That should work.

0
source share

All Articles