zoukankan      html  css  js  c++  java
  • Python安装xlrd和xlwt的步骤以及使用报错的解决方法

    一、安装xlrd和xlwt功能模块步骤

    1.使用python -V查看python的版本号,并查看python安装环境,是否安装成功;
     
    2.可以通过官网(python官网:https://pypi.python.org/pypi)或者其他手段获取到功能模块的安装程序包;
     
    3.将程序包解压,并放在python->Lib文件下
     
    4.在cmd命令窗口中,进入E:PythonPython36Lib目录下,分别进入xlrd和xlwt的目录下,执行python setup.py install命令;

    5.在python工具中,执行import xlwt3和import xlrd,运行结果没有报错,则证明安装成功;
     
    二、在使用xlwt时,报错的解决方法
    1.导入xlwt3报错:ValueError: cannot use LOCALE flag with a str pattern
    详细错误信息:
    Traceback (most recent call last):
      File "F:/1/1", line 1, in <module>
        import xlwt3
      File "E:PythonPython36libsite-packagesxlwt3\__init__.py", line 3, in <module>
        from .workbook import Workbook
      File "E:PythonPython36libsite-packagesxlwt3workbook.py", line 5, in <module>
        from .worksheet import Worksheet
      File "E:PythonPython36libsite-packagesxlwt3worksheet.py", line 7, in <module>
        from .row import Row
      File "E:PythonPython36libsite-packagesxlwt3 ow.py", line 8, in <module>
        from . import formula
      File "E:PythonPython36libsite-packagesxlwt3formula.py", line 1, in <module>
        from .excel import formulaparser, formulalexer
      File "E:PythonPython36libsite-packagesxlwt3excelformulalexer.py", line 52, in <module>
        VERBOSE+LOCALE+IGNORECASE)
      File "E:PythonPython36lib e.py", line 233, in compile
        return _compile(pattern, flags)
      File "E:PythonPython36lib e.py", line 301, in _compile
        p = sre_compile.compile(pattern, flags)
      File "E:PythonPython36libsre_compile.py", line 562, in compile
        p = sre_parse.parse(p, flags)
      File "E:PythonPython36libsre_parse.py", line 866, in parse
        p.pattern.flags = fix_flags(str, p.pattern.flags)
      File "E:PythonPython36libsre_parse.py", line 833, in fix_flags
        raise ValueError("cannot use LOCALE flag with a str pattern")
    ValueError: cannot use LOCALE flag with a str pattern
    解决方法:
    进入E:PythonPython36Libsre_parse.py文件下,修改该代码:
     if flags & SRE_FLAG_LOCALE:
                pass #stone20170712  raise ValueError("cannot use LOCALE flag with a str pattern")
    执行import xlwt3,结果OK
    2.导入xlwt3报错:ValueError: '__init__' in __slots__ conflicts with class variable
    详细错误信息:
    Traceback (most recent call last):
      File "F:/1/1", line 1, in <module>
        import xlwt3
      File "E:PythonPython36libsite-packagesxlwt3\__init__.py", line 3, in <module>
        from .workbook import Workbook
      File "E:PythonPython36libsite-packagesxlwt3workbook.py", line 5, in <module>
        from .worksheet import Worksheet
      File "E:PythonPython36libsite-packagesxlwt3worksheet.py", line 7, in <module>
        from .row import Row
      File "E:PythonPython36libsite-packagesxlwt3 ow.py", line 8, in <module>
        from . import formula
      File "E:PythonPython36libsite-packagesxlwt3formula.py", line 6, in <module>
        class Formula(object):
    ValueError: '__init__' in __slots__ conflicts with class variable
    解决方法:
    进入E:PythonPython36Libsite-packagesxlwt3formula.py文件下,将其中
    __slots__ = [ "__init__","__s", "__parser", "__sheet_refs", "__xcall_refs"]
    修改为:
    __slots__ = [ "__s", "__parser", "__sheet_refs", "__xcall_refs"]
    执行import xlwt3,结果OK
     
     
     
     
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    Can't remove netstandard folder from output path (.net standard)
    website项目的reference问题
    The type exists in both DLLs
    git常用配置
    Map dependencies with code maps
    How to check HTML version of any website
    Bootstrap UI 编辑器
    网上职位要求对照
    Use of implicitly declared global variable
    ResolveUrl in external JavaScript file in asp.net project
  • 原文地址:https://www.cnblogs.com/kongjiangbing/p/7158269.html
Copyright © 2011-2022 走看看