Search code examples
python-2.7parallelsxlwings

Error with XlWings on mac with parallels


I try to open the fibonacci template on my mac using Microsoft Excel from Parallels but I get the following error (xlwings version 0.4.1). The file is well opened automatically with Microsoft Excel and the error comes.

Has someone any idea on how to correct that ?

In[39]: wb = Workbook(r'/Users/Downloads/fibonacci.zip Folder/fibonacci.xlsm')
Traceback (most recent call last):
  File "/Users/anaconda/lib/python2.7/site-   packages/IPython/core/interactiveshell.py", line 3035, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-39-8750713fa323>", line 1, in <module>
wb = Workbook(r'/Users/Downloads/fibonacci.zip Folder/fibonacci.xlsm')
  File "/Users/anaconda/lib/python2.7/site-packages/xlwings/main.py", line 158, in __init__
self.name = xlplatform.get_workbook_name(self.xl_workbook)
  File "/Users/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 102, in get_workbook_name
return xl_workbook.name.get()
  File "/Users/anaconda/lib/python2.7/site-packages/aeosa/appscript/reference.py", line 498, in __call__
raise CommandError(self, (args, kargs), e, self.AS_appdata)
CommandError: Command failed:
    OSERROR: -1708
    MESSAGE: Application could not handle this command.
    COMMAND: app(u'/Users/Applications (Parallels)/{716d2333-63ae-4f42-a203-ae81a0a171db} Applications.localized/Microsoft Excel.app').workbooks['fibonacci.xlsm'].name.get()

Solution

  • If you want to use the Windows version of Excel from Mac through Parallels, you need to drive things from a Windows based Python installation, too (e.g. from the Windows Command Prompt instead of Mac Terminal).

    If instead you want to drive Mac Excel 2011 or 2016 and in case Parallels is giving you a hard time, specify the path of the Mac Excel installation through app_target, see the docs or this question.