Reputation: 43
I am completely new here. This is my first post, however I have been an SO member for a couple months, reading questions and answers. I need help figuring out how to import an xlsx file. My goal is eventually to learn how to manipulate and extrapolate data.
CMD Prompt for PIP
C:\Users\adtoes>pip install xlrd
Requirement already satisfied: xlrd in c:\python27\lib\site-packages
CODE:
import xlrd
file_location = "D:/SampleData/Sampledata.xlsx"
work = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(0)
Console output for Thonny
Python 3.6.4
>>> import xlrd
Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
ModuleNotFoundError: No module named 'xlrd'
Thanks,
Adam
Upvotes: 4
Views: 7812
Reputation: 7012
If you're using Thonny's default settings, then it uses a built-in Python 3 virtual environment. To install stuff into this environment use "Tools => Manage packages ..." or "Tools => Open System shell ...".
Upvotes: 1
Reputation: 14096
You're installing the package in Python 2
and trying to import it from Python 3
Try this:
python2
>>> import xlrd
Upvotes: 4