Linux version of Openpyxl does not open .xlsx files

Issue #438 resolved
Timothy Lombard
created an issue

Hi Charlie- Thanks for looking at this...

at least three of the .xlsx files I was able to open and read in the MacOS version of my scripts can not be opened in Linux. Below are the setup and traceback for each instance.

import openpyxl cpgatt = "/ws/tlombard-sjc/Picklejar/CSG_CHG_Clarity_attributes2.xlsx" cpgatt_wb = openpyxl.load_workbook(cpgatt) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/excel.py", line 149, in load_workbook _load_workbook(wb, archive, filename, read_only, keep_vba) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/excel.py", line 237, in _load_workbook keep_vba=keep_vba) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 324, in read_worksheet fast_parse(ws, xml_source, shared_strings, style_table, color_index) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 312, in fast_parse parser.parse() File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 93, in parse dispatchertag_name File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 189, in parse_row_dimensions self.parse_cell(cell) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 134, in parse_cell cell = Cell(self.ws, column, row, **style) TypeError: init() got an unexpected keyword argument 'quotePrefix'

----------------------------- Next file -------------------------

chgdept = "/ws/tlombard-sjc/Picklejar/CHGdeptlist20141114.xlsx" chgdept_wb = openpyxl.load_workbook(chgdept) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/excel.py", line 149, in load_workbook _load_workbook(wb, archive, filename, read_only, keep_vba) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/excel.py", line 237, in _load_workbook keep_vba=keep_vba) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 324, in read_worksheet fast_parse(ws, xml_source, shared_strings, style_table, color_index) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 312, in fast_parse parser.parse() File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 93, in parse dispatchertag_name File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 189, in parse_row_dimensions self.parse_cell(cell) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 134, in parse_cell cell = Cell(self.ws, column, row, style) TypeError: __init__() got an unexpected keyword argument 'pivotButton' ---------------------------- Third and Final File ---------------------- dspend = "/ws/tlombard-sjc/Picklejar/SandeepSpendQ2FY15.xlsx" dspend_wb = openpyxl.load_workbook(dspend) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/excel.py", line 149, in load_workbook _load_workbook(wb, archive, filename, read_only, keep_vba) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/excel.py", line 237, in _load_workbook keep_vba=keep_vba) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 324, in read_worksheet fast_parse(ws, xml_source, shared_strings, style_table, color_index) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 312, in fast_parse parser.parse() File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 93, in parse dispatchertag_name File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 189, in parse_row_dimensions self.parse_cell(cell) File "/auto/elb_hwtools/cae/lib/python/v2.7.8/openpyxl/reader/worksheet.py", line 134, in parse_cell cell = Cell(self.ws, column, row, style) TypeError: init() got an unexpected keyword argument 'quotePrefix' ------------------------------------- My environment ------------

tlombard-lnx-v1:146> uname -a Linux tlombard-lnx-v1 2.6.32-279.19.1.el6.x86_64 #1 SMP Sat Nov 24 14:35:28 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

tlombard-lnx-v1:147> python -V Python 2.7.8

tlombard-lnx-v1:148> python Python 2.7.8 (default, Dec 11 2014, 14:38:34) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import openpyxl print openpyxl.version 2.2.0

Comments (6)

  1. Charlie Clark

    Thanks for the report. There should be no difference between OSes so I can only assume you have different versions of openpyxl installed.

    The error is due to the change in the way styles are handled in 2.2 which is exposing a couple of attributes we've never really modelled before. Until we get a fix for this there are two possible workarounds: use read_only mode if you only want the data; or downgrade to 2.1.5.

  2. Timothy Lombard reporter

    Greetings Charlie- you make good point about the version of openpyxl I''m using on my Mac.

    TLOMBARD-M-60V2:~ tlombard$ uname -a

    Darwin TLOMBARD-M-60V2 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

    TLOMBARD-M-60V2:~ tlombard$ python

    *Python 2.7.8 (default, Oct 19 2014, 16:03:53) *

    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin

    Type "help", "copyright", "credits" or "license" for more information.

    >>> import openpyxl

    >>> print openpyxl.version

    2.0.3

    --------------------------------------

    Thanks too for your work-around suggestions. I will ask my kind sys admin to downgrade our version to 2.1.5 and try re-running my scripts. If that works, I will also upgrade my Mac to the same version.

    Charlie- Please know that I really appreciate this module and use is in some pretty crazy applications with my work. I'm not a classical programmer yet do data science work related to engineering operations for a pretty big network company using python to pull data from several sources - SQL form Oracle HR Databases, XML responses from web services, and my own experience based dictionaries to write excel files that I push into Tableau to tell stories.

    Thank you! Should you ever get down-under in Australia (Melbourne is a pretty nice place :-) ) , please know, I'm good for a pint or two of our local brews. /Timothy Lombard

  3. Charlie Clark

    pip install openpyxl==2.1.5 should do the trick.

    Not sure how relevant it is for you but the Pivot Tables you have will get lost when reading the file anyway. The current workaround for this is write a Macro to create them but this is also currently being repaired as well.

    I hardly use Excel myself but accept it as the lingua franca for data exchange. Did some contract work on openpyxl for the AusVet association last year. Don't know if I'll ever make it downunder but if I do I'll hold you to that offer!

  4. Log in to comment