pythonexcelopenpyxlpyexcel

pyexcel / openpyxl __init__() got an unexpected keyword argument ERROR


I am receiving the following error stack when attempting to upload files back to our application. The application takes xlsx sheets and is able to parse them and upload the content back up to SalesForce. I did some digging into this issue and it appears it might be something to do with openpyxl in terms of compatibility but I am not 100% sure. It appears others have had this issue as well but It doesn't appear to be any solutions listed. Has anyone else encountered this problem?

load_workbook error for 1707 version excel & pip install/upgrade error openpyxl

https://bitbucket.org/openpyxl/openpyxl/issues/636/error-when-loading-outlookcom-web-excel

 Traceback (most recent call last):
   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1817, in wsgi_app
     response = self.full_dispatch_request()
   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1477, in full_dispatch_request
     rv = self.handle_user_exception(e)
   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1381, in handle_user_exception
     reraise(exc_type, exc_value, tb)
   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1475, in full_dispatch_request
     rv = self.dispatch_request()
   File "/usr/lib/python2.6/site-packages/flask/app.py", line 1461, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "/var/www/html/nurfi/run.py", line 139, in upload_file
     responses = upload_nurfi_files(files_to_upload)
   File "/var/www/html/nurfi/nurfinstein.py", line 134, in upload_nurfi_files
     statuses[filename] = upload_sheet(file_, sf, verbose_mode = False )
   File "/var/www/html/nurfi/nurfi_app/upload/upload_nurfi.py", line 74, in upload_sheet
     book_dict = pyexcel.get_book_dict(file_name = workbook_name)
   File "/usr/lib/python2.6/dist-packages/pyexcel/core.py", line 343, in get_book_dict
     book = get_book(**keywords)
   File "/usr/lib/python2.6/dist-packages/pyexcel/core.py", line 118, in get_book
     book_stream = _get_book(**keywords)
   File "/usr/lib/python2.6/dist-packages/pyexcel/core.py", line 137, in _get_book
     sheets = source.get_data()
   File "/usr/lib/python2.6/dist-packages/pyexcel/sources/file_source_input.py", line 52, in get_data
     sheets = get_data(self.file_name, streaming=True, **self.keywords)
   File "/usr/lib/python2.6/dist-packages/pyexcel_io/io.py", line 31, in get_data
     file_type=file_type, **keywords)
   File "/usr/lib/python2.6/dist-packages/pyexcel_io/io.py", line 120, in load_data_new
     reader.open(file_name, **keywords)
   File "/usr/lib/python2.6/dist-packages/pyexcel_xlsx/xlsx.py", line 87, in open
     self._load_from_file()
   File "/usr/lib/python2.6/dist-packages/pyexcel_xlsx/xlsx.py", line 127, in _load_from_file
     data_only=True)
   File "/usr/lib/python2.6/dist-packages/openpyxl/reader/excel.py", line 234, in load_workbook
     parser.parse()
   File "/usr/lib/python2.6/dist-packages/openpyxl/reader/worksheet.py", line 106, in parse
     dispatcher[tag_name](element)
   File "/usr/lib/python2.6/dist-packages/openpyxl/reader/worksheet.py", line 295, in parse_data_validation
     dv = DataValidation.from_tree(node)
   File "/usr/lib/python2.6/dist-packages/openpyxl/descriptors/serialisable.py", line 78, in from_tree
     return cls(**attrib)
 TypeError: __init__() got an unexpected keyword argument '{http://schemas.microsoft.com/office/spreadsheetml/2014/revision}uid'

Solution

  • So hopefully my time digging through this saves some other people some time. It appears that this issue can be resolved by updating openpyxl and one of its plugin dependents openpyxl_xlsx to the latest build. I would also recommend if you are using pyexcel to update that to the latest package as well as I believe it uses openpyxl as a dependent.

    sudo pip install openpyxl --upgrade
    sudo pip install openpyxl_xlsx --upgrade
    sudo pip install pyexcel --upgrade
    

    Or for specific versions...

    sudo pip install --upgrade 'package-name'==0.0.0 (Version Number)