ImportError: No module named xlrd
我想用Python处理Excel文件,在VS Code中写好如下的代码:
# -*- coding: UTF-8 -*-import xlrd
# 打开Excel文件
workbook = xlrd.open_workbook('10/test.xlsx')
# 输出所有sheet的名字
print(workbook.sheet_names())
# 获取所有的sheet
print(workbook.sheets())
# 根据索引获取sheet
print(workbook.sheet_by_index(1))
# 根据名字获取sheet
print(workbook.sheet_by_name('1班'))
运行后报错:
[Running] python -u "/Users/bobb/Desktop/Python/10/read_score.py"Traceback (most recent call last):
File "/Users/bobb/Desktop/Python/10/read_score.py", line 3, in <module>
import xlrd
ImportError: No module named xlrd
[Done] exited with code=1 in 0.039 seconds
如图:
搜索有关ImportError: No module named xlrd
的解决办法,大部分网友建议在终端运行pip3 install xlrd
指令,但是得到如下结果:
Requirement already satisfied: xlrd in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.2.0)
如下图所示:
请问这一步应该怎么办?
我检查了Python3的位置:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
也查看了在VS Code中interpreter path
是:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3
如图:
请问此时应该怎么办?是哪里出问题了?
编程小白自学python,请各位大神谅解和指点,感谢!
回答
python3 -u "/Users/bobb/Desktop/Python/10/read_score.py"
用python3启动
以上是 ImportError: No module named xlrd 的全部内容, 来源链接: utcz.com/a/34587.html