python - 将excel文件导入python脚本时出现ImportError
问题描述
所以我今天尝试将我的第一个 excel 文件导入到 VIM 中的 python 文档中,但并不顺利。值得注意的是,我不情愿地拥有 3 个版本的 Python,v2.7、3.6 和 3.7,其中 Python 3.6 是使用的版本。
我之前设法在 Vim 上启用了 python 模式,这似乎有效。而且我已经设法安装了熊猫,但 xlrd 似乎不起作用。
我正在尝试将名为 names.xsl 的 excel 文件导入到我的 lab5.py 脚本中,但每次运行 python 脚本时都会出现此错误:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pandas/io/excel.py", line 261, in __init__
import xlrd
ModuleNotFoundError: No module named 'xlrd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "lab5.py", line 2, in <module>
df = pd.read_excel (r'/home/Lab05/names.xsl')
File "/usr/lib/python3/dist-packages/pandas/util/_decorators.py", line 118, in wrapper
return func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pandas/io/excel.py", line 230, in read_excel
io = ExcelFile(io, engine=engine)
File "/usr/lib/python3/dist-packages/pandas/io/excel.py", line 263, in __init__
raise ImportError(err_msg)
ImportError: Install xlrd >= 0.9.0 for Excel support
烦人的部分是我已经安装了 xlrd 并且它告诉我要安装它?为什么是这样?到目前为止,这是我的 python 脚本:
1 import pandas as pd
2 df = pd.read_excel (r'/home/Lab05/names.xsl')
3 print (df)
解决方案
推荐阅读
- laravel - 为什么此代码有效并且如果子文档不存在,则雄辩地创建子文档?
- .net-core - 如何部署 .NET Core 3.1。只有特殊语言环境的应用程序
- javascript - 为什么我们没有在彼此内部链接承诺?
- python - 将 FOR 循环输出附加到列表 PYTHON
- java - POS:如何将每件商品的价格相加得到总价?
- spring-boot - Set-Cookies 响应标头 cookie 未正确并立即在 VPS 上设置
- ios - 我尝试在 iPhone 的后台显示 FCM 通知,但是当我使用 Swift 发送此通知时它不起作用
- javascript - 保存数组状态,稍后编辑
- c# - 需要帮助从 C# 中的 Web 服务读取 xml 响应
- css - 页面内容更改时 Fill-Height 属性出现问题