使用并行的Mac上的XlWings出错

时间:2015-10-18 16:24:02

标签: python-2.7 parallels xlwings

我尝试使用Parallels的Microsoft Excel在我的Mac上打开斐波纳契模板,但是我收到以下错误(xlwings版本0.4.1)。 使用Microsoft Excel自动打开文件,出现错误。

有人知道如何纠正这个问题吗?

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()

1 个答案:

答案 0 :(得分:1)

如果您想通过Parallels从Mac使用Windows版本的Excel,您还需要从基于Windows的Python安装中进行驱动(例如,从Windows命令提示符而不是Mac终端)。

如果您想驾驶Mac Excel 2011或2016而且Parallels给您带来困难,请通过app_target指定Mac Excel安装的路径,请参阅docs或{{ 3}}