简体   繁体   中英

ModuleNotFoundError: No module named 'xlrd'

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.

  1. IDE Thonny
  2. Py Version 3.6.4
  3. XLDR installed via PIP

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

You're installing the package in Python 2 and trying to import it from Python 3

Try this:

python2
>>> import xlrd

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 ...".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM