ImportError: No module named openpyxl.workbook

刘超 7月前 ⋅ 1039 阅读   编辑

一、描述

  pandas报错excel,报如下错误

Traceback (most recent call last):
  File "001创建文件.py", line 6, in 
    df.to_excel('Temp/output001.xlsx')
  File "/Library/Python/2.7/site-packages/pandas/core/generic.py", line 2127, in to_excel
    engine=engine)
  File "/Library/Python/2.7/site-packages/pandas/io/formats/excel.py", line 656, in write
    writer = ExcelWriter(_stringify_path(writer), engine=engine)
  File "/Library/Python/2.7/site-packages/pandas/io/excel.py", line 1204, in __init__
    from openpyxl.workbook import Workbook
ImportError: No module named openpyxl.workbook

二、解决方法

  1、使用如下命令检查是否存在openpyxl包,如下

pip list | grep openpyxl

  2、如下不存在,安装openpyxl

sudo pip install openpyxl


注意:本文归作者所有,未经作者允许,不得转载

全部评论: 0

    我有话说: