wb = xlwings.Workbook()在mac上失败

时间:2014-12-30 04:52:28

标签: python excel xlwings

我只是在Mac上修补xlwings以将值写入单元格。但是,当我初始化一个新工作簿时,我得到了这个:

import xlwings as xl
wb = xl.Workbook()


Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/Developer/anaconda/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/Developer/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 30, in clean_up
    app('Microsoft Excel').run_VB_macro('CleanUp')
  File "/Developer/anaconda/lib/python2.7/site-packages/aeosa/appscript/reference.py", line 579, in __getattr__
    raise AttributeError("Unknown property, element or command: %r" % name)
AttributeError: Unknown property, element or command: 'run_VB_macro'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/Developer/anaconda/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/Developer/anaconda/lib/python2.7/site-packages/xlwings/_xlmac.py", line 30, in clean_up
    app('Microsoft Excel').run_VB_macro('CleanUp')
  File "/Developer/anaconda/lib/python2.7/site-packages/aeosa/appscript/reference.py", line 579, in __getattr__
    raise AttributeError("Unknown property, element or command: %r" % name)
AttributeError: Unknown property, element or command: 'run_VB_macro' 

Excel会打开并创建一个新文件,但随后会发生异常。我不明白为什么在mac上运行时会尝试运行宏。我知道作者在这里。希望他可以权衡。

2 个答案:

答案 0 :(得分:0)

我在OS X Yosemite 10.10.2,Office 2011 v14.4.6,Python 3.4.2和xlwings 0.3.0上没有收到此错误。

也许你为Python 2.7安装了xlwings?请尝试以下命令su:pip3 install xlwings

答案 1 :(得分:0)

我唯一一次遇到这样的错误,问题在于我安装Anaconda的位置。我卸载了,并使用安装程序提供的默认位置重新安装它,之后一切正常。

以下是安装/卸载Anaconda的指南:http://docs.continuum.io/anaconda/install