zoukankan      html  css  js  c++  java
  • 导入openpyxl模块后运行会报错

    系统:window10

    语言:python

    模块:openpyxl

    环境:pycharm

    说明:openpyxl模块干嘛的?

    用来操作excel,这里作者是用来用excel存放测试数据使用。

    模块安装:命令pip install openpyxl

    E:>pip install openpyxl
    Collecting openpyxl
      Downloading https://files.pythonhosted.org/packages/95/8c/83563c60489954e5b80f9e2596b93a68e1ac4e4a730deb1aae632066d704/openpyxl-3.0.3.tar.gz (172kB)
    
        100% |████████████████████████████████| 174kB 9.5kB/s
    Requirement already satisfied: jdcal in g:helloworldpythonlibsite-packages (from openpyxl)
    Requirement already satisfied: et_xmlfile in g:helloworldpythonlibsite-packages (from openpyxl)
    Building wheels for collected packages: openpyxl
      Running setup.py bdist_wheel for openpyxl ... done
      Stored in directory: C:UsersMACHENIKEAppDataLocalpipCachewheels585cae768ac132e57e75e645a151f8badac71cc0089e7225dddf76b
    Successfully built openpyxl
    Installing collected packages: openpyxl
    Successfully installed openpyxl-3.0.3
    You are using pip version 9.0.1, however version 20.1.1 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.
    

    输入操作内容:

    import openpyxl

    #打开文件,同级不能获取路径
    excel_workbook = openpyxl.load_workbook('cases.xlsx')
    print(excel_workbook)

    #第二步,获取表单,类似字典操作,已经封装好了
    sheet = excel_workbook['Sheet1']
    print(sheet)

    运行出现报错:

    Traceback (most recent call last):
        import openpyxl
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxl\__init__.py", line 6, in <module>
        from openpyxl.workbook import Workbook
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlworkbook\__init__.py", line 4, in <module>
        from .workbook import Workbook
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlworkbookworkbook.py", line 7, in <module>
        from openpyxl.worksheet.worksheet import Worksheet
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlworksheetworksheet.py", line 24, in <module>
        from openpyxl.cell import Cell, MergedCell
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlcell\__init__.py", line 3, in <module>
        from .cell import Cell, WriteOnlyCell, MergedCell
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlcellcell.py", line 27, in <module>
        from openpyxl.styles import numbers, is_date_format
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlstyles\__init__.py", line 4, in <module>
        from .alignment import Alignment
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlstylesalignment.py", line 5, in <module>
        from openpyxl.descriptors import Bool, MinMax, Min, Alias, NoneSet
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxldescriptors\__init__.py", line 3, in <module>
        from .base import *
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxldescriptorsase.py", line 12, in <module>
        from openpyxl.utils.datetime import from_ISO8601
      File "G:helloWorldpythonPython3.7.7libsite-packagesopenpyxlutilsdatetime.py", line 12, in <module>
        from jdcal import (
    ModuleNotFoundError: No module named 'jdcal'
    

      

    此时打开pycharm设置

    点击+号,搜索输入openpyx;

    再次运行:

    <openpyxl.workbook.workbook.Workbook object at 0x0000025C7A2E0E88>
    <Worksheet "Sheet1">
    

    完美解决!

  • 相关阅读:
    建模算法(十)——灰色理论之关联度分析
    建模算法(八)——插值
    建模算法(七)——排队论模型
    建模算法(六)——神经网络模型
    建模算法(五)——图与网络
    [gpio]Linux GPIO简单使用方式2-sysfs
    [Kernel]理解System call系统调用
    [gpio]Linux GPIO简单使用方式1-sysfs
    [misc]如何在嵌入式平台使用printf功能
    [wifi]wifi模块操作
  • 原文地址:https://www.cnblogs.com/mengjinxiang/p/12952464.html
Copyright © 2011-2022 走看看