ImportError: No module named xlrd

2024/11/20 21:37:45

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 pddf = 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?

Answer

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!!

https://en.xdnf.cn/q/26278.html

Related Q&A

How do I automatically fix lint issues reported by pylint?

Just like we have "eslint --fix" to automatically fix lint problems in Javascript code, do we have something for pylint too for Python code?

Conversion from JavaScript to Python code? [closed]

Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines. It is not currently accepting answers.We don’t allow questi…

connect to a DB using psycopg2 without password

I have a postgres database on my localhost I can access without a password$ psql -d mwt psql (8.4.12) Type "help" for help.mwt=# SELECT * from vatid;id | requester_vatid |...-----+---------…

Shebang doesnt work with python3

I have the following program:#!/usr/local/bin/python3print("Hello")Via terminal I do test.py and I get:Traceback (most recent call last):File "/usr/lib/python3.3/site.py", line 629,…

Why does pip freeze list pkg-resources==0.0.0?

On Ubuntu 16.04 with virtualenv 15.0.1 and Python 3.5.2 (both installed with apt) when I create and activate new Python virtual environment withvirtualenv .virtualenvs/wtf -p $(which python3) --no-site…

How to delete an instantiated object Python?

I am relatively new to object oriented programming and I cannot figure out how to delete an instantiated object in Python. if self.hit_paddle(pos) == True or self.hit_paddle2(pos) == True:bar = bar + 1…

Call method from string

If I have a Python class, and would like to call a function from it depending on a variable, how would I do so? I imagined following could do it:class CallMe: # Classdef App(): # Method one...def Foo(…

Scipy sparse... arrays?

So, Im doing some Kmeans classification using numpy arrays that are quite sparse-- lots and lots of zeroes. I figured that Id use scipys sparse package to reduce the storage overhead, but Im a little …

Using virtualenv with spaces in a path

I set up a virtualenv environment on my Mac, but cannot get Pip to install packages. It fails with the following error:/Volumes/Macintosh: bad interpreter: No such file or directoryI tracked the proble…

What is the difference between a stack and a frame?

Under what situations would I want to use one over the other?What is the difference between:>>> import inspect >>> print(inspect.getouterframes(inspect.currentframe())) [(<frame o…